2016-07-26 97 views
0

我使用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爲相同的電子郵件即時獲取orgNameorgTitle在一個變量

回答

0

您可以使用GET方法到URL端點「https://www.google.com/m8/feeds/contacts/ {userEmail}/full」從谷歌檢索聯繫人。你也可以通過link。它會幫助你。

+0

使用上面的url作爲https://www.google.com/m8/feeds/contacts/default/full?&oauth_token = 1234567894我得到了xml響應,但它沒有獲取完整的響應。例如,我無法獲得 software

相關問題