0

我在尝试从用户的个人资料中提取总上传视图时遇到问题。这是我目前拥有的脚本。一切正常,直到我尝试拉getTotalUploadViews()

任何人都知道我该如何解决这个问题?

global $yt;
// set protocol version to 2 to retrieve a v2 profile entry,
// which contains additional information from the user's profile
$yt->setMajorProtocolVersion(2);
// enter a username or set the $userName variable to 'default'
// to retrieve the currently authenticated user's profile
$userProfileEntry = $yt->getUserProfile($userName);
 echo "<h3>Profile Information</h3><br />";
$userInfo = $userProfileEntry->getUsername();
 echo '<span><a href="http://youtube.com/user/'.$userInfo.'"><h4><img src="img/youtube.jpg" style="height:20px;width:20px;" /> '.$userInfo.'</h4></a></span><br />';
$proImage = $userProfileEntry->getThumbnail()->getUrl();
 echo '<img src="'.$proImage.'" style="height:150px;" class="img-polaroid"/><br />';
 echo '<hr>';


// retrieve counts of favorites, contacts, subscriptions and uploads
// by examining the feedLink elements in the profile
$statistics = $userProfileEntry->getStatistics();
 echo '<br /><br />';
 echo 
  '
    <div class="tabbable tabs-left" id="info-tabs">
      <ul class="nav nav-tabs">
        <li class="active">
          <a href="#bi" data-toggle="tab">Member Info</a>
        </li>
        <li>
          <a href="#vi" data-toggle="tab">Channel Statistics</a>
        </li>
        <li>
          <a href="#oi" data-toggle="tab">Other Info</a>
        </li>
      </ul>
    <div class="tab-content" id="tabed-info">
      <div class="tab-pane fade in active" id="bi">
      <p>
        <strong>Member Since: '.$userProfileEntry->getPublished()->text.'</strong><br />
        <strong>Last Update: '.$userProfileEntry->getUpdated()->text.'</strong>
      </p>
      </div>
      <div class="tab-pane fade" id="vi">
        <p>
          <strong>Favorite Videos: '.$userProfileEntry->getFeedLink('http://gdata.youtube.com/schemas/2007#user.favorites')->countHint.'</strong><br />
          <strong>User Contacts: '.$userProfileEntry->getFeedLink('http://gdata.youtube.com/schemas/2007#user.contacts')->countHint .'</strong><br />
          <strong>Subscriptions: '.$userProfileEntry->getFeedLink('http://gdata.youtube.com/schemas/2007#user.subscriptions')->countHint.'</strong><br />
          <strong>Video Uploads: '.$userProfileEntry->getFeedLink('http://gdata.youtube.com/schemas/2007#user.uploads')->countHint.'</strong><br />
        </p>
      </div>
      <div class="tab-pane fade" id="oi">
        <p>
          <strong>Channel Views: '.$statistics->getViewCount().'</strong><br />
          <strong>Videos Watched: '.$statistics->getVideoWatchCount().'</strong><br />
          <strong>Subscribers Count: '.$statistics->getSubscriberCount().'</strong><br />
          <strong>Test: '.$statistics->getTotalUploadViews().'</strong>
        </p>
      </div>
    </div>
    </div>
  ';

在我尝试回<strong>'.$statistics->getTotalUploadViews().'</strong>显页面后,只加载了一半。

4

1 回答 1

0

getTotalUploadViews() 不是 Zend_Gdata_YouTube_Extension_Statistics 类的方法。

您在哪里看到该方法名称?

更新:

看起来这是 YouTube 提供的属性,但 Zend Statistics 类没有明确处理。然而——看起来 Zend 类将任何无法识别的属性保存到一个通用的“extensionAttributes”数组中。

尝试调用$statistics->getExtensionAttributes()并查看您需要的值是否包含在返回值中。

<pre>
<?php print_r($statistics->getExtensionAttributes()); ?>
</pre>
于 2013-06-01T23:23:07.463 回答