Нужно выудить название всех видео которые есть на канале и вывести их виде таблицы на сайт. Как я не бился сколько не искал не чего толком не получается. Дошел до сайта You Tube DATA API зарегистрировался cloud platform где получил API Keys и OAuth 2.0 Client IDs файл json. Так вот сайт выдает такой код для публикации:
Спойлер (Отобразить)PHP:
скопировать код в буфер обмена
<?PHP /** * Sample PHP code for youtube.videos.list * See instructions for running these code samples locally: * https://developers.google.com/explorer-help/guides/code_samples#php */ throw new Exception (sprintf('Please run "composer require google/apiclient:~2.0" in "%s"', __DIR__ ));} require_once __DIR__ . '/vendor/autoload.php'; $client = new Google_Client(); $client->setApplicationName('API code samples'); $client->setScopes([ 'https://www.googleapis.com/auth/youtube.readonly', ]); // TODO: For this request to work, you must replace // "YOUR_CLIENT_SECRET_FILE.json" with a pointer to your // client_secret.json file. For more information, see // https://cloud.google.com/iam/docs/creating-managing-service-account-keys $client->setAuthConfig('YOUR_CLIENT_SECRET_FILE.json'); $client->setAccessType('offline'); // Request authorization from the user. $authUrl = $client->createAuthUrl(); printf("Open this link in your browser:\n%s\n", $authUrl); print('Enter verification code: '); // Exchange authorization code for an access token. $accessToken = $client->fetchAccessTokenWithAuthCode($authCode); $client->setAccessToken($accessToken); // Define service object for making API requests. $service = new Google_Service_YouTube($client); $queryParams = [ 'id' => 'Ks-_Mh1QhMc,c0KYU2j0TM4,eIho2S0ZahI' ]; $response = $service->videos->listVideos('snippet,contentDetails,statistics', $queryParams);
Секретный файл подставил ошибка ушла и секретный ключ прописал и теперь новая ошибка связанная с инденитификацией:
Спойлер (Отобразить)
CODE ( htmlphp):
скопировать код в буфер обмена
Fatal error: Uncaught InvalidArgumentException: missing the required redirect URI in W:\domains\test\vendor\google\auth\src\OAuth2.php:675 Stack trace: #0 W:\domains\test\vendor\google\apiclient\src\Client.php(396): Google\Auth\OAuth2->buildFullAuthorizationUri() #1 W:\domains\test\you_tube.php(28): Google\Client->createAuthUrl() #2 W:\domains\test\index.php(22): include('W:\\domains\\test...') #3 {main} thrown in W:\domains\test\vendor\google\auth\src\OAuth2.php on line 675
Помогите решить проблему я уже без сил.
|