문제

I have following link http://gdata.youtube.com/feeds/api/videos/tYMYv1zsAxE and it return an xml file in which is located noembed tag in case the video is not embeddable.

i want to create a loop on list of videos to check which is embeddable and which is not.

도움이 되었습니까?

해결책

Based on your clarification, it sounds like you're asking a question about parsing XML. Here's an alternative: get back JSON, and parse that. You can make a request like

http://gdata.youtube.com/feeds/api/videos/tYMYv1zsAxE?v=2&alt=jsonc&prettyprint=true

and then look at the data->accessControl->embed element within the JSON response.

Or, you know, just parse and access the YouTube API XML exactly like you'd parse the XML from any other source. There's nothing magic going on with the YouTube API XML.

다른 팁

$vidID = "tYMYv1zsAxE";
$url="http://gdata.youtube.com/feeds/api/videos/$vidID?v=2&alt=jsonc&prettyprint=true";
$json = file_get_contents($url, true);
$json_output = json_decode($json);
echo $json_output->data->accessControl->embed;

Simple way to check if youtube video is embeddable.

Thanks to @Jeff Posnick

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top