Эти плейлисты могут быть общедоступными, частными или частными.
Я могу получить общедоступные плейлисты, но я изо всех сил пытаюсь получить частные и частные плейлисты, даже если настроен oAuth.
Вот мой код
Код: Выделить всё
public function getPlaylist()
{
$client = new Client();
$client->setLogger(new \Monolog\Logger('google-api'));
$client->setApplicationName('Playlists');
$client->setAuthConfig(base_path('youtube.json'));
// Exchange authorization code for an access token.
if (Session::has('google_oauth_token')) {
$client->setAccessToken(Session::get('google_oauth_token'));
}
$service = new YouTube($client);
$queryParams = [
'channelId' => config('scraper.channelId'),
'maxResults' => 50,
'mine' => 1,
];
$response = $service->playlists->listPlaylists('snippet, contentDetails, status,id', $queryParams);
dd($response);
}
Код: Выделить всё
{ "error": { "code": 400, "message": "Incompatible parameters specified in the request: channelId, mine", "errors": [ { "message": "Incompatible parameters specified in the request: channelId, mine", "domain": "youtube.parameter", "reason": "incompatibleParameters", "location": "parameters.", "locationType": "other" } ] } }
Если я оставлю параметр mine и удалю идентификатор канала, я получу следующую ошибку:
Код: Выделить всё
{ "error": { "code": 404, "message": "Channel not found.", "errors": [ { "message": "Channel not found.", "domain": "youtube.playlist", "reason": "channelNotFound", "location": "channelId", "locationType": "parameter" } ] } }
Спасибо за помощь в этом вопросе
Подробнее здесь: https://stackoverflow.com/questions/791 ... -playlists