Tuesday, April 15, 2008

use curl function instead of file_get_contents

hi
use curl function instead of file_get_contents
because if you use file_get_contents u may get "http request failed" error;

PHP Warning: file_get_contents(http://static.heywatch.com/thumbs/E9aGH0nw8D/Butterfly.flv.jpg) [function.file-get-contents]: failed to open stream: HTTP request failed! in /usr/local/dzoic/heywatch/ping_after_encode.php on line 36

so avoid that we can use,

//get video content using CURL library
$ch = curl_init($real_url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$video_content = curl_exec($ch);
curl_close($ch);


please note: curl should be enabled/configured in your system


No comments:

Post a Comment