How do I check if a video exists on YouTube, using PHP?(如何使用 PHP 检查 YouTube 上是否存在视频?)
问题描述
如何使用 PHP 检查 YouTube 上是否存在视频?
How do I check if a video exists on YouTube, using PHP?
推荐答案
使用 Youtube 的 API 怎么样?
毕竟,这意味着使用一些官方文件,与解析一些 HTML 页面相比,更改的可能性较小.
What about using Youtube's API?
After all, that would mean using some official, which is less likely to change than going with parsing some HTML page.
有关详细信息:YouTube API 和工具 - 开发人员指南:PHP
For more information: YouTube APIs and Tools - Developer's Guide: PHP
检索特定视频条目似乎很有趣:如果您向这样的 URL 发送请求:
The Retrieving a specific video entry seems quite interesting: if you send a request to an URL like this one:
http://gdata.youtube.com/feeds/api/videos/videoID
(用视频的 ID 替换videoID",当然,在你的例子中是GeppLPQtihA"),如果视频有效,你会得到一些 ATOM 提要;如果不是,则为无效 ID"
(replacing "videoID" by the ID of the video, of course – "GeppLPQtihA" in your example), you'll get some ATOM feed if the video is valid; and "Invalid id" if it's not
而且,我坚持:这样,您依赖于文档化的 API,而不是依赖于今天存在但不能保证的某种行为.
And, I insist: this way, you rely on a documented API, and not on some kind of behavior that exists today, but is not guaranteed.
这篇关于如何使用 PHP 检查 YouTube 上是否存在视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 PHP 检查 YouTube 上是否存在视频?


基础教程推荐
- Web 服务器如何处理请求? 2021-01-01
- 将变量从树枝传递给 js 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- php中的foreach复选框POST 2021-01-01
- php中的PDF导出 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01