gpt4 book ai didi

php - 警告 file_get_contents() 无法打开流 : HTTP request failed! HTTP/1.0 402 需要付款

转载 作者:搜寻专家 更新时间:2023-10-31 22:01:08 24 4
gpt4 key购买 nike

我今天遇到了这个错误,但在此之前,我的代码运行良好。

代码在本地主机上运行良好,但在我的网站上出现错误

这是产生错误的代码行:

$data = file_get_contents("https://www.youtube.com/get_video_info?hl=en&video_id={$_GET['id']}&eurl=&el=detailpage&gl=US&ps=default");

和错误:

Warning: file_get_contents(https://www.youtube.com/get_video_info?hl=en&video_id=SD3S27fMGzc&eurl=&el=detailpage&gl=US&ps=default): failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required in /home/zyxs/public_html/site.com/vid/youtube.php on line 2

最佳答案

试试这个

function http_get_contents($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (FALSE === ($retval = curl_exec($ch))) {
echo curl_error($ch);
} else {
return $retval;
}
}

$request_url = 'http://gdata.youtube.com/feeds/api/videos/SD3S27fMGzc';
$result = http_get_contents($request_url);

$simpleXML = new SimpleXMLElement($result);

print_r($simpleXML);

关于php - 警告 file_get_contents() 无法打开流 : HTTP request failed! HTTP/1.0 402 需要付款,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28995506/

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