Embedding a YouTube Video Based on a PHP Variable

一曲冷凌霜 提交于 2019-12-24 22:14:07

问题


I have a website that I am creating for a class project. The website shows information about bands (which is stored in a mysql database). I am trying to spruce up the site a bit, and I would like to embed a YouTube video based on the band's name. Say, for instance, I have "Led Zeppelin" stored in my database. How can I take a PHP variable containing "Led Zeppelin", search YouTube using that variable, find a random video, and then embed that in the website? From the research I've done, it seems you can only embed YouTube videos if you know the exact address of the video. Thanks!


回答1:


See Youtube API




回答2:


You can do that using the youtube PHP API http://code.google.com/apis/youtube/2.0/developers_guide_php.html#Searching_for_Videos




回答3:


You can use a script that match you search query or tags from youtube API like http://www.scriptsmashup.com/include_mytube_demo.php



来源:https://stackoverflow.com/questions/2525168/embedding-a-youtube-video-based-on-a-php-variable

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