I'm using the Google Contacts API and I'm able to extract names and email addresses , phone number , image but I'd like to also get contact address , note and also how to extract email as work or home
I'm using PHP and here's my code while authenticating:
$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);
}
}
how to fetch contact address . they(google api) mentioned formattedAddress , structuredPostalAddress but dont how to fetch and also find if it is home or work
EDIT
As mentioned in below answer im getting xml response but that response is not complete. because contact details also contain birth date,anniversary,website details so this details are not fetch via
https://www.google.com/m8/feeds/contacts/default/full?&oauth_token=abcdferyyrfyfyt
and also the remaining data im getting is as
<gd:organization rel='http://schemas.google.com/g/2005#other'><gd:orgName>comright</gd:orgName><gd:orgTitle>software developer</gd:orgTitle></gd:organization>
so for this when i tried foreach loop
as same for email im getting orgName
and orgTitle
in one variable
You can Use the GET method to the url endpoint " https://www.google.com/m8/feeds/contacts/ {userEmail}/full" to retrieve the contacts from google. You can also go through the link .It will help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.