How do I check if a video exists on YouTube, using PHP?

后端 未结 14 1670
[愿得一人]
[愿得一人] 2020-11-27 06:40

How do I check if a video exists on YouTube, using PHP?

14条回答
  •  囚心锁ツ
    2020-11-27 07:00

    You want to validate if a youtube url is an url to a real youtube video? This is quite hard, you could use regular expressions, but keep in mind that there are loads of valid ways to express a youtube url:

    • http://www.youtube.com/watch?v=p72I7g-RXpg
    • http://www.youtube.com/watch?asv=76621-2&v=p72I7g-RXpg
    • http://www.youtube.com/v/RdPxlTX27Fk
    • etc.

    Also the video code can contain alphanumeric characters, underscores, -characters (dunno what they are called) and possibly more.

提交回复
热议问题