Reputation: 365
I have created project on https://developers.google.com/ and I have an apikey with type server and by using it with YouTube api v3.0 as here
$params['apikey'] = 'api-key-here';
$this->load->library('youtube', $params);
$feed = $this->youtube->getMostViewedVideoFeed(array('max-results' => 30));
print_r($feed);
But when I run this code it will returning blank. blank screen. So what is the solution for that. I have tested in localhost.
Upvotes: 0
Views: 643
Reputation: 758
I am assuming you are using below library for fetching the data.
https://github.com/jimdoescode/CodeIgniter-YouTube-API-Library/blob/master/libraries/Youtube.php
But this library is built with version 2 and Google has stopped the version 2.you can check it on below link
Note: The YouTube Data API (v2) has been officially deprecated as of March 4, 2014. Please refer to our deprecation policy for more information. Please use the YouTube Data API (v3) for new integrations and migrate applications still using the v2 API to the v3 API as well.
Reference : https://developers.google.com/youtube/2.0/developers_guide_protocol
So you need to build your library based on version 3 for that you can checkout the below documentation.
https://developers.google.com/youtube/v3/code_samples/php.
For e.g. if you want to get most popular videos. you can try below.
https://www.googleapis.com/youtube/v3/videos?chart=mostPopular&key={YOUR_API_KEY}&part=snippet&maxResults=4
I hope this will help you.
Upvotes: 2