YouTube API PHP-无法检索完整的视频说明 [英] YouTube API PHP - Trouble retrieving full video description

查看:103
本文介绍了YouTube API PHP-无法检索完整的视频说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在玩 google/google-api-php-client .我注意到它显示为"build-failing",但是某些部件正在按预期工作,因此我一直坚持使用它.

因此,我建立了一个搜索字段,用于查询YouTube API以获取包含搜索字符串的视频并打印结果.您会发现,如果单击了视频,我还将连接YouTube Player iFrame API来播放视频.

现在,这些结果确实包含摘要数据(标题,描述,channelId等),但是项目描述的长度限制为160个字符,并附加省略号.

因此,现在为了获取完整的说明,我正在向YouTube API发送另一个调用.我正在呼叫$youtube->videos->listVideos('snippet',array('id' => '7dR02ebri9c')).调用成功,但不包含任何代码段数据.

我已将响应记录到控制台,因此您可以在这里看到它:

并在此处打印,以防上面的图像不显示. {"etag":"\"43qFkeEQBKio26KDSq1ZQMzjhSo/3nlK0uyD_p1CFvvGkbiQcGORv5w\"","eventId":null,"kind":"youtube#videoListResponse","nextPageToken":null,"prevPageToken":null,"visitorId":null}

如果我通过 YouTube API资源管理器运行相同的请求, ,我收到了包含摘要数据和完整说明的完整回复.

所以我问,问题是 google/google-api-php-client 我使用的是YouTube API本身,还是其他?

我已经找到并考虑过使用 madcoda/php-youtube- api ,并且会这样做-如果其他所有方法都失败了.

解决方案

我发现 google/google-api-php-client 是这里的问题.

我已经成功地使用 madcoda/php-youtube-api .

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.

解决方案

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

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

这篇关于YouTube API PHP-无法检索完整的视频说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆