user3379482
user3379482

Reputation: 567

How to retrieve a youtube video keywords with php

I'm trying to get videos keywords using video id (or url).
I've googled it and found ways to get videos info (title, length,..etc) but didn't find a way to get keywords.
So..how to retrieve a youtube video keywords with php

code:

    $entry = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/gzDS-Kfd5XQ?v=2');
    $keywords = (string) $entry->children('media', TRUE)->group->keywords;

    $keywords_array = explode(", ", $keywords);
    print_r($keywords_array);

Upvotes: 3

Views: 949

Answers (2)

Pedro Lobito
Pedro Lobito

Reputation: 99081

You need the YouTube API for that.

you'll be looking for:

snippet.tags[]

https://developers.google.com/youtube/v3/docs/videos#properties

Get you credentials on Google APIs Console

Example query:

https://www.googleapis.com/youtube/v3/videos?part=snippet&id=Lg7vPFnTuMg&order=date&key=YOURKEY

Upvotes: 1

Obadah Hammoud
Obadah Hammoud

Reputation: 572

Buddy you will get something like:

    Array
    (

because you must be the uploader of the video - you must provide a key first..
simply you can't extract it from videos you don't own!!

Upvotes: 2

Related Questions