Youtube api 3.0 getting information for one video

I am trying to get data for a single video using Youtube api 3.0, and I cannot figure out how to do this.

I managed to make this example pretty easy: https://developers.google.com/youtube/v3/code_samples/php

and tune it a bit.

But now I'm trying to get information for one video with a specific identifier.

Here i'm trying

$data = $youtube->videos->list("snippet"); 

and it always gives me this error

Unable to disable line offsets at {SERVER_PATH} /Google_ServiceResource.php on line 95

If anyone can help, I would really appreciate it.

+6
source share
4 answers

can't give you exact php code but url is like this

 String url = "https://www.googleapis.com/youtube/v3/videos?id="+videoID+"&key=" + YOUR KEY HERE + "&fields=items(id,snippet(channelId,title,categoryId),statistics)&part=snippet,statistics"; 

you get a JSON object that you parse :)

+10
source

I donโ€™t know if you understood this yet, because some time has passed, but I believe that you are calling a function that does not exist. I think it should be:

 $data = $youtube->videos->listVideos("snippet"); 
+1
source

Using AngularJS

 app.controller('oneVideoCtrl', function($scope, $http, $stateParams, $location){ $scope.videos = []; $scope.youtubeParams = { key: 'YOUR-API-KEY-HERE', type: 'video', kind: 'youtube#video', maxResults: '1', part: 'id,snippet', order: 'viewCount', channelId: 'YOUR-CHANNEL-ID-HERE', playlistId: 'YOUR-PLAYLIST-ID-HERE', } // Get single specific YouTube video $http.get('https://www.googleapis.com/youtube/v3/videos?id=VIDEO-ID-HERE', {params:$scope.youtubeParams}).success(function(response){ angular.forEach(response.items, function(child){ console.log (child); $scope.videos.push(child); }); }); }); 
0
source

Exact request using the Youtube v3 API:

 https://www.googleapis.com/youtube/v3/videos?id=VIDEO_ID_HERE&fields=items(snippet(title))&part=snippet&key=API_KEY_HERE 

And you get the following:

 { "items": [ { "snippet": { "title": "VIDEO_TITLE_HERE" } } ] } 
-1
source

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


All Articles