【发布时间】:2025-12-07 09:25:01
【问题描述】:
我想使用 php 根据他们的 id 检索有关 Youtube 视频的信息。
我有我的 API 密钥,我正在尝试这个:
$res = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=snippet&id=<vid-id>&key=<my-key>");
echo $res;
但我收到此警告:
file_get_contents(https://www.googleapis.com/youtube/v3/videos?part=snippet&id=<vid-id>&key=
):打开流失败:HTTP 请求失败! HTTP/1.0 400 错误请求
响应头如下所示:
["http_response_header"]=>
array(10) {
[0]=>
string(24) "HTTP/1.0 400 Bad Request"
[1]=>
string(45) "Content-Type: application/json; charset=UTF-8"
[2]=>
string(35) "Date: Sun, 25 May 2014 09:50:12 GMT"
[3]=>
string(38) "Expires: Sun, 25 May 2014 09:50:12 GMT"
[4]=>
string(33) "Cache-Control: private, max-age=0"
[5]=>
string(31) "X-Content-Type-Options: nosniff"
[6]=>
string(27) "X-Frame-Options: SAMEORIGIN"
[7]=>
string(31) "X-XSS-Protection: 1; mode=block"
[8]=>
string(11) "Server: GSE"
[9]=>
string(28) "Alternate-Protocol: 443:quic"
}
现在我被困住了。我不知道下一步该怎么做才能找出问题所在。我错过了什么吗?我做错了吗?我不知道。
有什么提示吗?
编辑
感谢 hakre,我能够找到错误消息“accessnotconfigured”。
通过* Entry (second response),我突然想到要创建一个新项目。
然后我跳过了输入推荐人,现在它可以工作了!
问题是什么,我不知道。我怀疑这与推荐人有关。
【问题讨论】:
-
+1 对于您的第一个问题,请提供一个具体示例并展示您是如何进行调试的。也为了您解释您如何修复它以及您使用了哪些来源。欢迎使用 *!
标签: php youtube youtube-api