YouTube API PHP - Trouble retrieving full video description

旧城冷巷雨未停 提交于 2019-12-25 03:14:44

问题


I've been playing around with the google/google-api-php-client. I've noticed that it says "build-failing", but some parts are working as expected, so I've been pressing on with it.

So I have built a search field that queries the YouTube API for videos containing a search string and prints the results. You'll see that I've also hooked up the YouTube Player iFrame API to play the video if it is clicked.

Now these results do contain snippet data (title, description, channelId, etc...), but the item description's are limited to 160 characters and appended with an ellipsis .

So now in an attempt to get a full description, I am sending another call to the YouTube API. I am calling $youtube->videos->listVideos('snippet',array('id' => '7dR02ebri9c')). The call is successful, but does not contain any snippet data.

I've logged the response to the console so you can see it here:

And printed it here incase the above image does not show. {"etag":"\"43qFkeEQBKio26KDSq1ZQMzjhSo/3nlK0uyD_p1CFvvGkbiQcGORv5w\"","eventId":null,"kind":"youtube#videoListResponse","nextPageToken":null,"prevPageToken":null,"visitorId":null}

If I run the same request via the YouTube API Explorer, I receive a response complete with snippet data and a full description.

So I ask, is the problem the google/google-api-php-client I am using, the YouTube API itself, or perhaps something else?

Edit: I've found and thought about using madcoda/php-youtube-api instead, and will do-so if all else fails.


回答1:


I've discovered that google/google-api-php-client was the problem here.

I've had success using madcoda/php-youtube-api instead.



来源:https://stackoverflow.com/questions/29001782/youtube-api-php-trouble-retrieving-full-video-description

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!