atrum Posted June 10, 2011 Share Posted June 10, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/238994-curl-and-fopen-warnings-need-a-little-guidance/ Share on other sites More sharing options...
Ollifi Posted June 10, 2011 Share Posted June 10, 2011 $fp = fopen("index.php","r"); //Open the file for reading only Opens file index.php in your local server. Do you want that? Maybe you can just try the example directly (just change the URL) from php reference curl_init Quote Link to comment https://forums.phpfreaks.com/topic/238994-curl-and-fopen-warnings-need-a-little-guidance/#findComment-1228037 Share on other sites More sharing options...
atrum Posted June 10, 2011 Author Share Posted June 10, 2011 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/238994-curl-and-fopen-warnings-need-a-little-guidance/#findComment-1228060 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.