使用 PHP 中的 API v3 在 Youtube 上获取视频详细信息 [英] Fetch video details on Youtube using API v3 in PHP

查看:31
本文介绍了使用 PHP 中的 API v3 在 Youtube 上获取视频详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过 PHP 中的 API v3 从 Youtube 获取视频详细信息?我需要帮助来开始这个.我已经尝试过本教程,但它不起作用.http://www.w3resource.com/API/youtube/tutorial.php

How can I fetch video details from Youtube via API v3 in PHP? I need help in getting started with this. I tried this tutorial already but it's not working. http://www.w3resource.com/API/youtube/tutorial.php

我需要搜索我的网站,我只需要获取详细信息,例如链接、缩略图、标题和上传视频的人.

I need to search through my site and I will only need to fetch the details such as link, thumbnails, title and the person who uploaded the video.

推荐答案

ref.https://developers.google.com/youtube/v3/docs/videos/list

您可以从您的服务器请求如下.
https://www.googleapis.com/youtube/v3/videos?part=snippet&id=XS6ysDFTbLU&key=XXX

You can request from your server as below.
https://www.googleapis.com/youtube/v3/videos?part=snippet&id=XS6ysDFTbLU&key=XXX

XXX 是您的 API 密钥.
如果您没有 API 密钥,则应访问开发者控制台,并获取 API 密钥.
http://code.google.com/apis/console#access
[API &auth]-[Credentials]-[公共API访问]-[创建新密钥]-[服务器密钥]
您应该在IPS"中设置服务器的全局 IP 地址.

XXX is your API key.
If you don't have your API key, you should access Developer Console, and you get API key.
http://code.google.com/apis/console#access
[APIs & auth]-[Credentials]-[Public API access]-[Create new key]-[Server key]
You should set global IP address of your server in "IPS".

如果你想从客户端调用API,你应该使用[创建新密钥]-[浏览器密钥]并在REFERERS"中设置你的URL.

If you want to call API from client, you should use [Create new key]-[Browser key] and set your URLs in "REFERERS".

如果您的问题是我可以获取数据,但我无法解析响应.",请参阅库文档.
https://github.com/google/google-api-php-client

If your question is "I can get data, but I can not parse response.", see documents of library.
https://github.com/google/google-api-php-client

这篇关于使用 PHP 中的 API v3 在 Youtube 上获取视频详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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