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? Link to comment https://forums.phpfreaks.com/topic/295147-retrieve-my-youtube-videos/ Share on other sites More sharing options...
Lone_Ranger Posted March 7, 2015 Author Share Posted March 7, 2015 anyone? Link to comment https://forums.phpfreaks.com/topic/295147-retrieve-my-youtube-videos/#findComment-1507839 Share on other sites More sharing options...
Lone_Ranger Posted March 7, 2015 Author Share Posted March 7, 2015 Solved it done, dusted all upgraded from API 2 to API 3 Link to comment https://forums.phpfreaks.com/topic/295147-retrieve-my-youtube-videos/#findComment-1507843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.