Retrieve a list of videos from Youtube channels using Youtube API v3 (no annoying popup)

I have a youtube channel and I use Youtube API v3 to pull out a list of videos uploaded to this channel (using php libraries ). The following is a snippet of the code I'm using:

require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_YouTubeService.php';
session_start();

$OAUTH2_CLIENT_ID = 'xxxxxxxxx';
$OAUTH2_CLIENT_SECRET = 'xxxxxxxxx';

$client = new Google_Client();
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);

$redirect = filter_var('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'], FILTER_SANITIZE_URL);
$client->setRedirectUri($redirect);

$youtube = new Google_YoutubeService($client);

$channelsResponse = $youtube->channels->listChannels('contentDetails', array(
      'mine' => 'true',

However, I get an annoying pop-up that asks me to log in and authenticate to get the details. How can I get rid of this popup? I plan to write a cron task that will periodically iterate over the video list and save it in the database, so I do not want this authentication pop-up window.

NOTE. When I try to pull a video from a playlist, I do not ask for authentication and api functions smoothly

$playlistItemsResponse = $youtube->playlistItems->listPlaylistItems('snippet,status', array(
          'part' => 'snippet,contentDetails',
          'maxResults' => 50,
          'playlistId' => 'UUGpAMVStIfaQ32K-vhwNIxw'
        ));
+4
2

, OAuth2. , API.

listlistItems- > .

api explorer: https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.playlistItems.list?part=snippet&playlistId=PLjFEz-E0UPUxw3lFpnfV1dDA7OE7YIFRj&_h=2&

clientId Client Secret

API API API .

$client- > setAPIKey ($ api_key);

+3

YouTube . API YouTube YouTube.

$API_key    = 'Your_API_Key';
$channelID  = 'YouTube_Channel_ID';
$maxResults = 10;

$videoList = json_decode(file_get_contents('https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId='.$channelID.'&maxResults='.$maxResults.'&key='.$API_key.''));
+1

Source: https://habr.com/ru/post/1523776/


All Articles