0

我有来自 YouTube v2 的 JSON 响应:http://gdata.youtube.com/feeds/api/users/youtube/uploads?orderby=published&max-results=1&alt=json

它只返回一个我想要的视频条目。我想得到那个视频的标题?我目前使用了以下代码:

$URL = file_get_contents('http://gdata.youtube.com/feeds/api/users/youtube/uploads?orderby=published&max-results=1&alt=json');
$readjson = json_decode($URL);
$title = $readjson->{'feed'}->{'entry'}->{'title'}->{'$t'};
echo $title;

但它看起来不是普通的 JSON 树,因为它在视频中有一个数组,entry 所以我的代码不起作用。任何想法如何得到它?

4

1 回答 1

2
$title = $readjson->{'feed'}->{'entry'}[0]->{'title'}->{'$t'};
于 2013-02-16T17:53:28.560 回答