phpvideoyoutubeyoutube-apirelated-content

How can I get related videos with php on youtube api?


I want to get related videos on Youtube when user enters the video id on my system. But system will work like this:

  1. User will enter video id
  2. System will find related videos of the video that user entered.
  3. After that, system will choose one of the related videos and start to get that video's related vids list.
  4. System will repeat this for 10 times.
  5. And will show to user last video.

So, my problem is getting first video's related video and after last video's, after last video's etc... And my aim is try to find the journey from first video to last video.

How can I do this?


Solution

  • You can do this via search->list method specifying relatedToVideoId.

    You can use PHP API client.

    Here is a similar sample. https://github.com/youtube/api-samples/blob/master/php/search.php