Jump to content

Retrieve My YouTube Videos


Lone_Ranger
Go to solution Solved by Lone_Ranger,

Recommended Posts

require_once ($_SERVER["DOCUMENT_ROOT"].'/google-api-php-client/src/Google_Client.php');  
require_once ($_SERVER["DOCUMENT_ROOT"].'/google-api-php-client/src/contrib/Google_YouTubeService.php');  


  $DEVELOPER_KEY = 'xxx-xxx-xxx';

  $client = new Google_Client();  
  $client->setDeveloperKey($DEVELOPER_KEY);  
  $youtube = new Google_YoutubeService($client);  

  $channel = sentuamsg;

  try {
    $channelsResponse = $youtube->channels->listChannels('contentDetails', array(
      $channel => 'true',
    ));

    $htmlBody = '';
    foreach ($channelsResponse['items'] as $channel) {
      $uploadsListId = $channel['contentDetails']['relatedPlaylists']['uploads'];

      $playlistItemsResponse = $youtube->playlistItems->listPlaylistItems('snippet', array(
        'playlistId' => $uploadsListId,
        'maxResults' => 13
      ));

      $htmlBody .= "<h3>Videos in list $uploadsListId</h3><ul>";
      foreach ($playlistItemsResponse['items'] as $playlistItem) {
        $htmlBody .= sprintf('<li>%s (%s)</li>', $playlistItem['snippet']['title'],
          $playlistItem['snippet']['resourceId']['videoId']);
      }
      $htmlBody .= '</ul>';
    } 
  
   } catch (Google_ServiceException $e) {  
    $htmlBody .= sprintf('<p>A service error occurred: <code>%s</code></p>',  
      htmlspecialchars($e->getMessage()));  
  } catch (Google_Exception $e) {  
    $htmlBody .= sprintf('<p>An client error occurred: <code>%s</code></p>',  
      htmlspecialchars($e->getMessage()));  
  } 

Hi I have been working with API 2 recently but as we all know that is depreciated in April 2015 meaning all my work will be lost if I do not transfer over to API 3

 

I am trying to work API 3 out. What I am trying to do here is, I am trying to access the user account called SENTUAMSG, access his playlist PLZgnlVMqNnAok3nxF763JFz0WYWA6o783 and grabbed the 13 most recent uploaded videos to that playlist.

 

The information I would want to echo out is

 

- Video ID (id print after watch?v= from the youtube.com navigation)

- Thumbnail (the video thumbnail)

- Video Description

- Video Title

 

Anyone able to help me?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.