通过 API 获取 YouTube 视频的喜欢/不喜欢的数量? [英] Get the amount of likes/dislikes for a YouTube video via API?

查看:21
本文介绍了通过 API 获取 YouTube 视频的喜欢/不喜欢的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过 YouTube API 获取 YouTube 视频的喜欢/不喜欢数量?

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

推荐答案

你可以这样查询YouTube API:

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);

}

?>

这篇关于通过 API 获取 YouTube 视频的喜欢/不喜欢的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆