Page 1 of 1

1.6.6a failed to open stream errors

PostPosted: 23. March 2008 14:47
by vincentrich
I am getting failed to open stream errors from all my file() functions and other related functions. It was fine before I upgraded.

Any idea what is causing this problem?

PostPosted: 23. March 2008 15:45
by Wiedmann
I am getting failed to open stream errors- Any idea what is causing this problem?

You have an error in your code.

(Nothing more to say, wihout the original error message, and a code sample...)

PostPosted: 23. March 2008 15:55
by vincentrich
Code: Select all
#INITIALISE DELICIOUS ADD POST API CALL
   $delicious_api_call = "https://" . $username . ":" . $password . "@api.del.icio.us/v1/posts/add?url=$url&description=$description&tags=$tags";
   
   #LAUNCH DELICIOUS ADD POST API CALL
   $result = file("$delicious_api_call");


This is my code. It used to work on my previous XAMPP version 1.6.2.

PostPosted: 23. March 2008 15:56
by vincentrich
The URL in the variable above works if I enter it into a browser.

PostPosted: 23. March 2008 16:09
by Wiedmann
The complete error message?

PostPosted: 23. March 2008 16:18
by vincentrich
Code: Select all
Warning: file(https://...@api.del.icio.us/v1/posts/add?url=http://www.domain.com/) [function.file]: failed to open stream: No error in C:\Projects\functions.php on line 342

PostPosted: 23. March 2008 16:19
by vincentrich
No idea why the URL works in the browser but PHP cannot find it. file_exists returns nothing.

PostPosted: 24. March 2008 03:18
by vincentrich
I put the URL in an Iframe and it works. I have no idea why the PHP file function refuses to work.

PostPosted: 24. March 2008 04:19
by vincentrich
Code: Select all
#THIS FUNCTION RETRIEVES THE CONTENTS OF A FILE WHEN FOPEN/FILE FUNCTION FAILS
function get_content($url)
{
   #OPEN CURL SESSION
   $handle = curl_init();
   
   #CURL SETTINGS
   curl_setopt($handle, CURLOPT_URL, $url);
   curl_setopt($handle, CURLOPT_HEADER, 0);
   curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
   
   #OUTPUT BUFFERING START
   ob_start();
   
   #EXECUTE CURL COMMAND
   curl_exec($handle);
   
   #CLOSE CURL SESSION
   curl_close($handle);
   
   #RETRIEVE URL CONTENTS
   $string = ob_get_contents();
   
   #OUTPUT BUFFERING END
   ob_end_clean();
   
   return $string;
}


I tried to use curl instead of file() and it worked only after I added:

Code: Select all
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);


I was trying to load a https URL so the code above was necessary.