我正在为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)列表?
答案 0 :(得分: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'];
}
}
}