0
我正在嘗試使用youtube登錄對應用系統進行編碼。但我有一個問題在我得到oauth 2.0所需的授權後,我想要選擇一個字符串中的YouTube頻道ID,但我無法做到這一點,有人可以幫助我。如何在Google Oauth之後獲取頻道ID或網址PHP
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->setApplicationName("BYTNETWORK");
$client->setScopes(array('https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/yt-analytics.readonly'
));
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
} else {
$authUrl = $client->createAuthUrl();
}
所以在此之後我要像
$的channelID = 「XXXXX」 的字符串;在下面的代碼中使用它
$data = file_get_contents('http://gdata.youtube.com/feeds/api/users/$channelid?alt=json');
$data = json_decode($data, true);
$stats_data = $data['entry']['yt$statistics'];
$medya = $data['entry']['media$thumbnail'];
//yt$username kısmından kanal adı parse edilir
/**********************************************************/
echo "<img src='$medya[url]'></img><br>";
echo "Subscribers: $stats_data[subscriberCount]<br>";
echo "Views: $stats_data[totalUploadViews]<br>";