我使用Google Contacts API,并且能够提取姓名和电子邮件地址,电话号码,图像,但我也想获得联系地址,备注和也Google Contacts API获取所有联系方式(php)
我使用PHP如何提取电子邮件作为办公室或家里,这里是我的代码,而认证:
$document = new DOMDocument();
$document->loadXml($xmlresponse);
$xpath = new DOMXpath($document);
$xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
$xpath->registerNamespace('gd', 'http://schemas.google.com/g/2005');
foreach ($xpath->evaluate('/atom:feed/atom:entry') as $entry) {
$contact = [
'name' => $xpath->evaluate('string(atom:title)', $entry),
'image' => $xpath->evaluate('string(atom:link[@rel="http://schemas.google.com/contacts/2008/rel#photo"]/@href)', $entry),
'emails' => [],
'numbers' => [],
'conatctaddress' => []
];
foreach ($xpath->evaluate('gd:email', $entry) as $email) {
$contact['emails'][] = $email->getAttribute('address');
}
foreach ($xpath->evaluate('gd:phoneNumber', $entry) as $number) {
$contact['numbers'][] = trim($number->textContent);
}
}
如何获取联系地址。他们(谷歌API)提到formattedAddress,structuredPostalAddress但不如何获取,也发现如果是在家中或工作
编辑
如下回答I M把XML响应提及,但这种反应是不完整的。因为联系方式也包含生日,周年纪念,网站细节,因此这个细节不通过
https://www.google.com/m8/feeds/contacts/default/full?&oauth_token=abcdferyyrfyfyt
并获取剩余的数据即时得到作为
<gd:organization rel='http://schemas.google.com/g/2005#other'><gd:orgName>comright</gd:orgName><gd:orgTitle>software developer</gd:orgTitle></gd:organization>
所以这个当我试图foreach loop
为相同的电子邮件即时获取orgName
和orgTitle
在一个变量
使用上面的url作为https://www.google.com/m8/feeds/contacts/default/full?&oauth_token = 1234567894我得到了xml响应,但它没有获取完整的响应。例如,我无法获得 –
software