2016-07-26 14 views
0

Google Contacts APIを使用しています。名前とメールアドレス、電話番号、画像を抽出できますが、連絡先、メモ、認証中に、私はPHPを使用していGoogleの連絡先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); 
    } 

} 

はどのように連絡先アドレスを取得します。彼ら(GoogleのAPI)はformattedAddress、structuredPostalAddressしかし、私は、XMLレスポンスを得るが、その応答が完了していないメートルの答えの下で述べたように取得し、また、それが家である場合見つけるか

EDIT

を操作する方法いけないを述べました。この詳細は

https://www.google.com/m8/feeds/contacts/default/full?&oauth_token=abcdferyyrfyfyt経由でフェッチされておらず、また、私は電子メールのために同じようforeach loopをしようとしたとき、残りのデータイム取得は

<gd:organization rel='http://schemas.google.com/g/2005#other'><gd:orgName>comright</gd:orgName><gd:orgTitle>software developer</gd:orgTitle></gd:organization>

ように、このためのものですので、連絡先の詳細はまた、誕生日、記念日、ウェブサイトの内容が含まれているため、 1つの変数に orgNameorgTitleを取得する

答えて

0

urlエンドポイント「https://www.google.com/m8/feeds/contacts/ {userEmail}/full」にGETメソッドを使用すると、Googleから連絡先を取得できます。あなたもlinkを通過することができます。それはあなたを助けるでしょう。

+0

上記のURLを 'https://www.google.com/m8/feeds/contacts/default/full?&oauth_token = 1234567894'として使用していますが、XMLレスポンスを取得していますが、完全なレスポンスを取得しません。例えば、私は software

関連する問題