【发布时间】:2017-04-02 02:00:06
【问题描述】:
美好的一天,
我尝试通过“OAuth 2.0 for server-to-server”检索我的 YouTube 频道拥有的私人播放列表(和相关视频);
但我只看到公共元素!
这是我的 PHP 代码:
$client = new Google_Client();
$client->setAuthConfig(__DIR__ . "/my_service_account.json");
$client->setScopes('https://www.googleapis.com/auth/youtube');
$client->setApplicationName("NameOfMyApp");
$client->refreshTokenWithAssertion();
$token = $client->getAccessToken();
$accessToken = $token['access_token'];
//---------
$YOUTUBE = new Google_Service_YouTube($client);
//---------
$arr_opt = array('channelId' => $MY_CHANNEL_ID );
$arr_playlist = $YOUTUBE->playlists->listPlaylists('snippet,contentDetails',$arr_opt);
var_export($arr_playlist);
我得到一个“正确”的对象, 但如果我的播放列表设置为“私有”,则“modelData”字段没有项目:
'modelData' =>
array (
'pageInfo' =>
array (
'totalResults' => 0,
'resultsPerPage' => 5,
),
'items' =>
array (
),
),
我忘记了什么?
这是 Youtube API 的限制?
通过我的 console.developers.google.com 对我的服务帐户进行错误配置?
感谢您的帮助!
【问题讨论】:
标签: php oauth youtube oauth-2.0 youtube-data-api