从 youtube xml 或 json 获取 youtube 标题
Get youtube title from youtube xml or json
我正在尝试从
获取 YouTube 视频标题
http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=dpe11FCFxBE&format=xml
在 xml 标题在
<oembed>
<title>
TITLE IS HERE
</title>
</oembed>
所以我尝试使用此代码获取标题,但它不起作用
$json_output = file_get_contents("http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=".$video_id."&format=xml");
$fln = $json['oembed']['title'];
试试这个代码...
$content = file_get_contents("http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=".$video_id."&format=json");
$json_output = json_decode($content, true);
$fln = $json_output['title'];
如果你想解析 json 输出,你应该使用 format=json
。
我正在尝试从
获取 YouTube 视频标题http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=dpe11FCFxBE&format=xml
在 xml 标题在
<oembed>
<title>
TITLE IS HERE
</title>
</oembed>
所以我尝试使用此代码获取标题,但它不起作用
$json_output = file_get_contents("http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=".$video_id."&format=xml");
$fln = $json['oembed']['title'];
试试这个代码...
$content = file_get_contents("http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=".$video_id."&format=json");
$json_output = json_decode($content, true);
$fln = $json_output['title'];
如果你想解析 json 输出,你应该使用 format=json
。