问题描述
我已经尝试了很长一段时间,以检查提交的链接是否来自youtube.com或vimeo.com的有效短片,但没有成功.
I have been trying for quite a while to check if submitted links are valid film-clips from youtube.com or vimeo.com but I didn't succeed.
关于如何检查url的任何想法:
Any ideas how to check url's like:
http://www.youtube.com/watch?v=jc0rnCBCX2c&feature=fvhl (valid)
http://www.youtube.com/watch?v=jc0FFCBCX2c&feature=fvhl (not valid)
http://www.youtube.com/v/jc0rnCBCX2c (valid)
http://www.youtube.com/v/ddjcddddX2c (not valid)
http://www.vimeo.com/463l522 (not valid)
http://www.vimeo.com/1483909 (valid)
http://www.vimeo.com/lumiblue (not valid)
http://www.youtube.com/user/dd181921 (not valid)
?
我使用php.
推荐答案
我在此网站上看到了一个答案:www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23765374.html
i see a answer in this site :www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23765374.html
他说:
我建议您使用youtube的API,因为您正在尝试验证视频是否存在.或者,如果您不想使用API,那么可以做一些简单的技巧.检查此链接:
I would suggest using youtube's API since you are trying to validate if the video exists.or if you don't want to go into API stuff then you can do simple trick.check this link:
http://code.google.com/apis/youtube/developers_guide_php. html#RetrievingVideoEntry
要检查视频是否存在,您需要提取"v"值并将包含视频ID的请求发送到:
to check for the existence of a video you will need to extract "v" value and send a request that contains the video id to :
http://gdata.youtube.com/feeds/api/videos/videoID
其中videoID是"v"值例如视频FLE2htv9oxc将被这样查询 http://gdata.youtube.com/feeds/api/videos/FLE2htv9oxc 如果它不存在,那么您将获得一个带有无效ID"的页面如果存在,则将返回一个XML提要,其中包含有关视频的各种信息.这样,您可以检查视频是否存在.
where videoID is the "v" valuefor example a video FLE2htv9oxcwill be queried like thishttp://gdata.youtube.com/feeds/api/videos/FLE2htv9oxcif it does not exist then you will get a page with "Invalid id"if it exists, will return an XML feed having various info about the video.this way you can check that the video exists.
希望这会为您提供正确的方向.
hope this will get you in the right direction.
与vimeo相同,请尝试在该站点的api文档中查找. http://www.vimeo.com/api
the same thing with vimeo , try to look in api documentation in there site.http://www.vimeo.com/api
这篇关于检查Youtube和Vimeo-clips是否有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!