【发布时间】:2019-02-19 05:15:54
【问题描述】:
我正在尝试使用我的参数调用 YouTube 频道 API,但出现以下错误。
[
"error" => array:3 [
"errors" => array:1 [
0 => array:5 [
"domain" => "youtube.parameter"
"reason" => "authorizationRequired"
"message" => "The request uses the <code>mine</code> parameter but is not properly authorized."
"locationType" => "parameter"
"location" => "mine"
]
]
"code" => 401
"message" => "The request uses the <code>mine</code> parameter but is not properly authorized."
]
]
通过下面的代码,我正在调用 youtube v3 API
$client = new \Google_Client();
$client->setAuthConfig(app_path('google-api.json'));
$client->setScopes([
'https://www.googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/youtubepartner-channel-audit',
\Google_Service_YouTube::YOUTUBE_FORCE_SSL,
]);
$client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/login');
$client->setAccessType('offline');
$client->setIncludeGrantedScopes(true);
$httpClient = $client->authorize();
$customerResponse = $httpClient->get('https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&mine=true&key={API_KEY}');
$customer = json_decode($customerResponse->getBody()->getContents(), true);
【问题讨论】:
标签: php youtube-api youtube-data-api