Search code examples
phpjsonvideoyoutubegdata

Get Channel Home Page URL from Json via PHP


I'm using JSON to get the video title, description, and author from the Youtube JSON API. How do I get the author's home page URL?

Data

I'm trying to get this.

I also noticed that sometimes, it's not youtube.com/channel/xxxx, but rather youtube.com/user/xxxx when I look at this:

hxxp://gdata.youtube.com/feeds/api/videos/hha0NsYXS5c?alt=json&prettyprint=true hxxps://www.youtube.com/user/TEDtalksDirector


Solution

  • For the example of

    http://gdata.youtube.com/feeds/api/videos/I6YeYnOTC-k?alt=json&prettyprint=true

    1. Get the URI of the author, given by the API (in this case "http://gdata.youtube.com/feeds/api/users/Zdr_9XUM9vrmkscUwnF42w")
    2. Make a request to get JSON-Output of the user
    3. Get the channel url under the link-href element(http://www.youtube.com/channel/UCZdr_9XUM9vrmkscUwnF42w)

    In the end you just grab the URI of the author, send a request to it and filter the JSON-Output.