Lone_Ranger Posted March 6, 2015 Share Posted March 6, 2015 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? Quote Link to comment Share on other sites More sharing options...
Lone_Ranger Posted March 7, 2015 Author Share Posted March 7, 2015 anyone? Quote Link to comment Share on other sites More sharing options...
Solution Lone_Ranger Posted March 7, 2015 Author Solution Share Posted March 7, 2015 Solved it done, dusted all upgraded from API 2 to API 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.