1

我正在为 ZF2 使用 ZendGData 库。

我试图获取帐户的数据,但没有关于配置文件的数据。

$email = $this->config['email'];
$password = $this->config['password'];

$service = \ZendGData\Analytics::AUTH_SERVICE_NAME;
$client = \ZendGData\ClientLogin::getHttpClient($email, $password, $service);
$analytics = new \ZendGData\Analytics($client);

print_r($analytics->getAccountFeed());

如何获取我的帐户的个人资料(或个人资料 ID)列表?

4

1 回答 1

1

我找到了解决方案:

$email = $this->config['email'];
$password = $this->config['password'];

$service = \ZendGData\Analytics::AUTH_SERVICE_NAME;
$client = \ZendGData\ClientLogin::getHttpClient($email, $password, $service);
$analytics = new \ZendGData\Analytics($client);

$profileResult = $analytics->getDataFeed($analytics->newAccountQuery()->profiles());

$profileIds = array();
/**
 * @var \ZendGData\Analytics\DataEntry $dataBit
 */
 foreach ($profileResult as $dataBit) {
     /**
       * @var \ZendGData\App\Extension\Element $element
       */
     foreach ($dataBit->getExtensionElements() as $element) {
         $attributes = $element->getExtensionAttributes();
         if ($attributes['name']['value']=='ga:profileId') {
             $profileIds[] = $attributes['value']['value'];
         }
    }
}
于 2012-10-19T09:36:29.467 回答