Chr*_*ris 1 youtube api zend-framework
我无法找到任何文档,我可以找到一个代码示例来接收视频的喜欢和不喜欢.这是我目前的代码:
$videoId = 'AyJl2NyQ0hI';
$videoEntry = $yt->getVideoEntry($videoId);
echo "Views: <strong>".$videoEntry->getVideoViewCount()."</strong><br />";
它工作得很好,但谁得到喜欢/不喜欢?谢谢.
只要看看通过源类Zend_Gdata_YouTube_VideoEntry和Zend_Gdata_YouTube_Extension_Statistics:
$videoEntry->getStatistics()->getViewCount();
编辑:您编辑了您的问题,现在正在寻找喜欢/不喜欢
步骤1:将协议版本更改为v2
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
第2步:zend gdata youtube客户端的最后一个稳定版本缺少访问喜欢和不喜欢的方法,但返回了数据.您可以通过查看评级扩展的扩展属性来获取它:
$videoId = 'AyJl2NyQ0hI';
$videoEntry = $yt->getVideoEntry($videoId);
foreach ($videoEntry->getExtensionElements() as $extension)
{
    if ($extension->rootElement == 'rating')
    {
        $attributes = $extension->getExtensionAttributes();
        var_dump($attributes);
    }
}
哪个应该返回:
array(2) {
  ["numDislikes"]=>
  array(3) {
    ["namespaceUri"]=>
    NULL
    ["name"]=>
    string(11) "numDislikes"
    ["value"]=>
    string(2) "57"
  }
  ["numLikes"]=>
  array(3) {
    ["namespaceUri"]=>
    NULL
    ["name"]=>
    string(8) "numLikes"
    ["value"]=>
    string(3) "657"
  }
}
| 归档时间: | 
 | 
| 查看次数: | 862 次 | 
| 最近记录: |