我可以通过Google Contacts API获取完整的联系人列表。这是代码:
$accessToken = $this->getAccessToken($sso, $authCode);
if (!$accessToken) {
return null;
}
$contacts = array();
$max_results = 100;
$get = array('max-results' => $max_results, 'oauth_token' => $accessToken, 'alt' => 'json');
$c = curlOutGet('https://www.google.com/m8/feeds/contacts/default/full', array('get'=>$get,'timeout'=>10),__FILE__.':'.__LINE__.':'.__FUNCTION__);
if ($c['c'] == 200) {
$jsonContacts = json_decode($c['r']);
foreach ($jsonContacts->feed->entry as $contact) {
$email = $contact->{'gd$email'}[0]->{'address'};
$email = testEmail($email) ? $email : null;
$contacts[] = array('email' => $email,
'title' => $contact->{'title'}->{'$t'},
);
}
}
但我想过滤给定的联系人。如何仅获取“我的联系人”列表中的联系人(显示在 Gmail 的联系人界面中)?我想过滤掉“其他联系人”列表中的联系人。
提前致谢!