0

I have this JSON response from YouTube v2: http://gdata.youtube.com/feeds/api/users/youtube/uploads?orderby=published&max-results=1&alt=json.

It only returns with one video entry as I wanted. I want to get the title of that video? I have currently used the following code:

$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;

but it looks like it's not a normal JSON tree, because it has an array in video entry so my code didn't work. Any ideas how to get that?

1 Answer 1

2
$title = $readjson->{'feed'}->{'entry'}[0]->{'title'}->{'$t'};
Sign up to request clarification or add additional context in comments.

3 Comments

Note that ->{'a'} is the same as ->a
(although ->{'$t'} is not the same as ->$t)
@Eric yes that would be a PHP value, Thanks again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.