YouTube频道订阅者人数 [英] Youtube channel subscriber count

查看:111
本文介绍了YouTube频道订阅者人数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试增加特定YouTube频道的订阅者数量.我提到了Stackoverflow上的一些链接以及外部站点,并遇到了> .几乎所有链接建议我使用youtube gdata api并从SubscriberCount中获取计数,但以下代码

I'm trying to pull the count of subscribers for a particular youtube channel. I referred some links on Stackoverflow as well as external sites, came across links like this. Almost all the links suggested me to use youtube gdata api and pull the count from subscriberCount but the following code

$data   = file_get_contents("http://gdata.youtube.com/feeds/api/users/Tollywood/playlists");
$xml    = simplexml_load_string($data);

print_r($ xml);

print_r($xml);

不返回任何此类SubscriberCount.还有其他方法可以使订户计数还是我做错了什么?

returns no such subscriberCount. Is there any other way of getting subscribers count or am I doing something wrong?

推荐答案

尝试一下;)

<?php 
$data = file_get_contents('http://gdata.youtube.com/feeds/api/users/Tollywood');

$xml = new SimpleXMLElement($data);
$stats_data = (array)$xml->children('yt', true)->statistics->attributes();
$stats_data = $stats_data['@attributes'];

/********* OR **********/

$data = file_get_contents('http://gdata.youtube.com/feeds/api/users/Tollywood?alt=json');
$data = json_decode($data, true);
$stats_data = $data['entry']['yt$statistics'];

/**********************************************************/

echo 'lastWebAccess = '.$stats_data['lastWebAccess'].'<br />';
echo 'subscriberCount = '.$stats_data['subscriberCount'].'<br />';
echo 'videoWatchCount = '.$stats_data['videoWatchCount'].'<br />';
echo 'viewCount = '.$stats_data['viewCount'].'<br />';
echo 'totalUploadViews = '.$stats_data['totalUploadViews'].'<br />';
?>

这篇关于YouTube频道订阅者人数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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