Php 如何从Youtube视频源获取视频ID?
我试图回显youtube视频源的ID,但它没有返回任何内容。我正在使用以下代码Php 如何从Youtube视频源获取视频ID?,php,youtube,Php,Youtube,我试图回显youtube视频源的ID,但它没有返回任何内容。我正在使用以下代码 $JSON = file_get_contents("http://gdata.youtube.com/feeds/api/videos?&v=2&q=dance&alt=json"); $JSON_Data = json_decode($JSON); foreach($JSON_Data->{'feed'}->{'entry'} as $video):
$JSON = file_get_contents("http://gdata.youtube.com/feeds/api/videos?&v=2&q=dance&alt=json");
$JSON_Data = json_decode($JSON);
foreach($JSON_Data->{'feed'}->{'entry'} as $video):
echo $video->{'id'};
endforeach;
当我在一个大数组中找不到正确的元素时,我总是使用print\u r()来打印它并找到它 这将是您的解决方案:
<?php
$JSON = file_get_contents("http://gdata.youtube.com/feeds/api/videos?&v=2&q=dance&alt=json");
$JSON_Data = json_decode($JSON);
foreach($JSON_Data->feed->entry as $video):
echo $video->id->{'$t'}."<br/>";
endforeach;
?>