How do I get the amount of likes/dislikes for a YouTube video via YouTube 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.
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”.
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);
}
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With