gpt4 book ai didi

ssl - file_get_contents() 无法在 youtube 上正常工作

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:41:53 24 4
gpt4 key购买 nike

我想从 youtube 获取数据,我正在使用 file_get_contents() 方法。

有时它工作正常但有时它不工作并显示以下错误

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

上面的错误是什么意思?

什么是SSL:加密启用超时

最佳答案

有时你不能,因为 SSL。使用 curl

这应该足够了:

$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);

关于ssl - file_get_contents() 无法在 youtube 上正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14100131/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com