Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the amount of likes/dislikes for a YouTube video via API?

How do I get the amount of likes/dislikes for a YouTube video via YouTube API?

like image 881
Kristina Brooks Avatar asked Sep 01 '10 14:09

Kristina Brooks


People also ask

Did YouTube remove dislikes from API?

Unfortunately, YouTube is removing the ability to access dislike counts through its API starting December 13, at least in part. The blog that announced the change has a bit of an addendum for developers: “Your end users will still be able to view dislike data related to their own content on authenticated API requests.

Why doesn't YouTube show how many dislikes a video has?

However, while you can still dislike videos, the total number of dislikes a video has is no longer visible. YouTube says it wanted to reduce “dislike attacking behavior” – where viewers would pile on the dislike button to drive the number up. YouTube says it hid the dislike count to prevent dislike “attacks”.


1 Answers

You can query the YouTube API like this:

<?php

$curlhandle = curl_init();
curl_setopt($curlhandle, CURLOPT_URL, "http://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&q=computers&max-results=10&orderby=viewCount");
curl_setopt($curlhandle, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($curlhandle);
curl_close($curlhandle);

$json = json_decode($response);


foreach ($json->data->items as $result)
{

        echo '<div class="video"><a href="'.$result->player->default.'" target="_blank">';
        echo '<img src="'.$result->thumbnail->hqDefault.'">';
        echo ' <div class="title"> '.$result->title.'</div><div class="rating">'.$result->likeCount.'</div></a></div>';
        //print_r($result);

}

?>

like image 94
Andy Avatar answered Oct 10 '22 22:10

Andy