I want to fetch data from youtube and I am using file_get_contents()
method.
sometime it works fine but sometime it do not works and shows the following error
file_get_contents() [function.file-get-contents]: SSL: crypto enabling timeout
file_get_contents() [function.file-get-contents]: Failed to enable crypto
file_get_contents(https://gdata.youtube.com/feeds/api/users/default?access_token=token&v=2&alt=json) [function.file-get-contents]: failed to open stream: operation failed
Maximum execution time of 30 seconds exceeded
What does the above errors mean?
What is SSL: crypto enabling timeout
You can't sometimes, because of SSL. Use cURL
This should suffice:
$ch = curl_init('https://youtube.com');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux i686; rv:20.0) Gecko/20121230 Firefox/20.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
echo curl_exec($ch);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With