【发布时间】:2014-01-26 12:32:58
【问题描述】:
我有一个 youtube 频道,我正在使用 Youtube API v3 来提取该频道中上传的视频列表(使用 php 库)。以下是我正在使用的代码的 sn-p:
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_YouTubeService.php';
session_start();
$OAUTH2_CLIENT_ID = 'xxxxxxxxx';
$OAUTH2_CLIENT_SECRET = 'xxxxxxxxx';
$client = new Google_Client();
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);
$redirect = filter_var('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'], FILTER_SANITIZE_URL);
$client->setRedirectUri($redirect);
$youtube = new Google_YoutubeService($client);
$channelsResponse = $youtube->channels->listChannels('contentDetails', array(
'mine' => 'true',
但是,我收到一个烦人的弹出窗口,要求我登录并进行身份验证以获取详细信息。我怎样才能摆脱这个身份验证弹出窗口? 我打算编写一个 cron 作业,它会定期提取视频列表并将其存储在数据库中,因此我不希望出现该身份验证弹出窗口。
注意:当我尝试从播放列表中提取视频时,不会要求我进行任何身份验证,并且 api 运行顺利
$playlistItemsResponse = $youtube->playlistItems->listPlaylistItems('snippet,status', array(
'part' => 'snippet,contentDetails',
'maxResults' => 50,
'playlistId' => 'UUGpAMVStIfaQ32K-vhwNIxw'
));
【问题讨论】:
标签: php youtube-api