[英]Google Contacts API get all contact details (php)
我正在使用Google Contacts API,并且能够提取姓名和电子邮件地址,电话号码,图片,但我还希望获得联系地址,注释以及如何在工作或家庭中提取电子邮件
我正在使用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,结构化PostalAddress,但不知道如何获取它,也不知道它是在家还是工作
编辑
如下所述,我正在获取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
,在一个变量中获取orgName
和orgTitle
您可以使用GET方法访问网址终结点“ https://www.google.com/m8/feeds/contacts/ {userEmail} / full”,以从Google检索联系人。 您也可以通过链接 。它将为您提供帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.