0
我正在研究一個使用Google的PHP API庫的項目。我目前使用的範圍與offline
訪問:通過訪問令牌訪問YouTube頻道標題需要什麼範圍?
https://www.googleapis.com/auth/youtube.force-ssl
https://www.googleapis.com/auth/youtube.upload
但是,這並沒有給我訪問得到證實的通道的通道標題。
然後我嘗試添加多個範圍:
https://www.googleapis.com/auth/youtube.readonly
https://www.googleapis.com/auth/youtubepartner
https://www.googleapis.com/auth/youtubepartner-channel-audit
但我也有同樣的結果。是否有一個範圍,這與我缺少的YouTube無關?
-
這裏是我使用的代碼,請注意$this->client
是Google_Client
一個實例:
/**
* Fetch channel title
*
* @return string
*/
public function fetchChannelTitle() {
/** @var \Google_Service_YouTube_Channel $details */
$details = $this->getChannelDetails();
$snippet = $details->getSnippet();
return $snippet->getTitle();
}
/**
* Get channel details
*
* @throws YouTubeException
*/
public function getChannelDetails()
{
if (!$this->access_token) {
throw new YouTubeException('NO_REFRESH_TOKEN');
}
$this->client->setAccessToken($this->access_token);
$parts = 'snippet,contentDetails,statistics';
$params = ['mine' => true];
$response = (new Google_Service_YouTube($this->client))->channels->listChannels(
$parts,
$params
);
return $response->getItems()[0];
}
我認爲_force SSL_範圍是一樣的_just_ YouTube的範圍。我會考慮這個 – dmb
包括兩個範圍 – noogui