Jump to content

Curl and fopen warnings Need a little guidance.


atrum

Recommended Posts

hello all,

 

I am trying to teach my self how to use curl to get the contents of a remote file.

 

I am using the example provided on the php.net website under the curl example.

 

 

<?php
//Curl driven verio api test
$ch = curl_init("http://curtisdorris.com/"); //Initialize the Curl Session.
$fp = fopen("index.php","r"); //Open the file for reading only

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

 

 

I am getting the following warnings and I am unable to find any information as to why I am getting them.

 

It still works but I really want to take care of these warnings before I continue further.

 

Warning: fopen(index.php) [function.fopen]: failed to open stream: No such file or directory in /home/UID/www/tools.exiled-alliance.com/apitest/curltest.php on line 4

 

Warning: curl_setopt(): supplied argument is not a valid File-Handle resource in /home/UID/www/tools.exiled-alliance.com/apitest/curltest.php on line 6

 

Can anyone offer any in-sight as to wtf is going on?

I actually got it figured out. I think that example is very out of date or something. I don't even need the fopen function to make it work.

 

I have a new issue now, but I will make a new post since it's not related to curl or fopen.

 

 

Thanks though.

 

 

Here is basically what I did.

<?php
$ch = curl_init(); //Initialize the Curl Session.

$headers = array(
"GET $path HTTP/1.1",
"Host: $host",
"Accept: $accept",
"Content-Type: $accept",
"Authorization: VKEY $keyid:$signature",
"Date: $date", "Connection: Close"
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $proxy);


$results = curl_exec($ch);
curl_close($ch);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.