Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-在OAuth之后获取通道ID-YouTube API_Php_Api_Oauth_Youtube_Youtube Data Api - Fatal编程技术网

PHP-在OAuth之后获取通道ID-YouTube API

PHP-在OAuth之后获取通道ID-YouTube API,php,api,oauth,youtube,youtube-data-api,Php,Api,Oauth,Youtube,Youtube Data Api,首先,这个问题听起来像是重复的,但从我已经看到的答案来看,我认为答案不符合这个目的,因为我没有得到许可 我正试图在他们授权他们的谷歌账户后找到YouTube频道ID 我使用的范围是: https://www.googleapis.com/auth/yt-analytics.readonly https://www.googleapis.com/auth/userinfo.profile 很多答案都涉及访问V3通道api以获取通道id $channelData = file_get_conten

首先,这个问题听起来像是重复的,但从我已经看到的答案来看,我认为答案不符合这个目的,因为我没有得到许可

我正试图在他们授权他们的谷歌账户后找到YouTube频道ID

我使用的范围是:

https://www.googleapis.com/auth/yt-analytics.readonly
https://www.googleapis.com/auth/userinfo.profile
很多答案都涉及访问V3通道api以获取通道id

$channelData = file_get_contents("https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&access_token=".$token['access']);
$channelData = json_decode($channelData, true);
问题在于我正在使用的作用域,您无法访问它。因此,其他问题都围绕着这个终点

请注意,我想保持范围绝对最小。为什么仅仅通过分析API就不可能做到这一点?我是否需要使用另一个YouTube范围来查找刚刚授权的人的频道id

我要问的问题是

是否有任何方法可以获取刚刚授权使用我当前作用域的用户的频道id?如果没有,我可以使用多少权限范围来获取他们的频道id?

[编辑]

抱歉,之前我错过了
auditDetails
部分。您可以在此处找到YouTube API作用域:


你肯定需要这个:
https://www.googleapis.com/auth/youtube
。我不确定这一点:
https://www.googleapis.com/auth/youtube.force-ssl
因为除了“强制ssl”部分之外没有任何解释。

你应该添加
youtube。只读的
范围,像
社交名流
这样的插件有这个范围的硬编码。频道
snippet
可以通过
channels
方法-使用
part=snippet
获得


只读范围足够轻,可以将其包含到列表中
userinfo.profile
yt analytics.readonly
无权访问频道列表。此范围是获取频道id所需的唯一范围。

谢谢您的回答。我不想得到审计细节部分。最好是代码片段或id。此外,(可能我错了),但我认为范围仅限于MCN/CMS持有者。我会做一些测试,然后回来!:)
$channelData = file_get_contents("https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&access_token=".$token['access']);
$channelData = json_decode($channelData, true);