我现在有点迷路。我想使用Youtube Api来获取所有已登录用户的订阅,并将它们显示为列表,但是我完全迷路了。我当时在考虑使用批处理请求,但是我什至不知道如何开始执行它。有什么建议么?
最佳答案
更新
使用Zend Framework - YouTube Data API。它不需要任何身份验证。
使用
1)从http://framework.zend.com/downloads/latest下载Zend Framework 1.12.3 Minimal
2)解压缩zip
。将文件夹Zend
复制到您的项目文件夹(或仅复制Zend\Gdata
)。
3)包括到index.php
(例如)类Zend_Gdata_YouTube
中:
<?php
require_once 'Zend/Gdata/YouTube.php';
$username = 'USERNAME'; // set need YouTube user
$yt = new Zend_Gdata_YouTube();
$subscriptionFeed = $yt->getSubscriptionFeed($username);
foreach ($subscriptionFeed as $subscriptionEntry) {
echo $subscriptionEntry->title->text . "\n";
}
?>
编辑1
使用
Youtube API
。checkin
php.ini
:extension=php_openssl.dll
比使用:
$userID = 'YouTubeUsedId';
$url_api = 'https://gdata.youtube.com/feeds/api/users/'.$userID.'/subscriptions?v=2';
$subs_content = file_get_contents($url_api);
获得带有订阅的
xml
后,请使用DomDocument
(例如)并获取用户列表。根据https://developers.google.com/youtube/2.0/developers_guide_protocol_subscriptions#Retrieving_subscriptions获取标签编辑2 (通知)
默认情况下,YouTube仅从视频供稿返回前25行。要进行偏移,请使用下一步:
$url='https://gdata.youtube.com/feeds/api/users/'.$userID.'/subscriptions?start-index=25
&max-results=25
&v=2';
start-index
从索引开始定义max-results
定义offest(注意:最大值= 50)。查看更多https://developers.google.com/youtube/2.0/reference?hl=it-IT&csw=1#max-resultssp
关于php - 如何使用php Youtube Api获取所有用户订阅?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21074975/