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 に答える