2016-04-08 20 views
0

kullanarak nasıl okudum? Google API’da yeniyim ve bir kullanıcının tüm kişilerini almak için People API’yı kullanmak istiyorum. Çalışıyor , ben kullanıcının kimliğini doğrulamak ve aşağıdaki gibi ben İnsanlar apı'sini:Google Kişiler API'sı tarafından döndürülen iletişim bilgilerini PHP

$contacts = $peopleService->people_connections->listPeopleConnections('people/me'); 
    foreach ($contacts as $contactItem) { 
    $this->print_r2($contactItem); 
    } 

Ama tip Google_Service_People_ListConnectionsResponse bir nesne edinin:

Google_Service_People_ListConnectionsResponse Object 
(
[collection_key:protected] => connections 
[internal_gapi_mappings:protected] => Array 
    (
    ) 

[connectionsType:protected] => Google_Service_People_Person 
[connectionsDataType:protected] => array 
[nextPageToken] => 
[nextSyncToken] => CPDp4aW_KhIBMRjuEioECAAQAQ 
[modelData:protected] => Array 
    (
     [connections] => Array 
      (
       [0] => Array 
        (
         [resourceName] => people/c3422388075840417635 
         [etag] => AgD+4rTZF6o= 
         [metadata] => Array 
          (
           [sources] => Array 
            (
             [0] => Array 
              (
               [type] => CONTACT 
               [id] => 2fc3d288898002f63 
               [etag] => #AgD+4rTZF6o= 
              ) 

            ) 

           [deleted] => 1 
           [objectType] => PERSON 
          ) 

        ) 

       [1] => Array 
        (
         [resourceName] => people/107483842333347794768 
         [etag] => btQbbIVcGJ4= 
         [metadata] => Array 
          (
           [sources] => Array 
            (
             [0] => Array 
              (
               [type] => CONTACT 
               [id] => 715e58866e51e374 
               [etag] => #TW+s5999ANk= 
              ) 

             [1] => Array 
              (
               [type] => PROFILE 
               [id] => 107483842299147794768 
              ) 

            ) 

           [objectType] => PERSON 
          ) 

         [names] => Array 
          (
           [0] => Array 
            (
             [metadata] => Array 
              (
               [primary] => 1 
               [source] => Array 
                (
                 [type] => CONTACT 
                 [id] => 715e50000e51e374 
                ) 

              ) 

             [displayName] => xxxxxxxx 
             [familyName] => xxxxxx 
             [givenName] => xxxxxxxxx 
             [displayNameLastFirst] => xxxxx, xxxxx 
            ) 

           [1] => Array 
            (
             [metadata] => Array 
              (
               [source] => Array 
                (
                 [type] => PROFILE 
                 [id] => ************************* 
                ) 

              ) 

             [displayName] => xxxxxxxxxx 
             [familyName] => xxxxx 
             [givenName] => xxxxxxx 
             [displayNameLastFirst] => xxxxx, xxxxxxx 
            ) 

          ) 

.... ..... ...

Sorum şu ki çok aptalca: PHP istemci kütüphanesini kullanarak, [modelData: protected] dizisini kullanarak nasıl elde edebilirim ki sonuçta [bağlantılar] oluşturabilirim.

+0

Olası kopyalar http://stackoverflow.com/soru/4414623/halka-rağmen-bir-dizi-php) – DaImTo

cevap

0

Sizinle aynı sorunları yaşıyorum, Google'ın geliştirici sitesindeki belgelerin repo açıkça v1 dalını kullanacağını belirtmesiyle hatalı görünüyor.

Bu

kötü kod nedir, şimdiye kadar birlikte saldırıya kadarıyla, ama umarım bu size yardımcı olacaktır:

$connections = $service->people_connections->listPeopleConnections('people/me', array(
    'pageSize' => 500, 
    'requestMask.includeField' => 'person.names,person.phoneNumbers' 
)); 

foreach($connections->connections as $contact){ 
    echo("{$contact[names][0][displayName]}<br/>"); 
} 
[Bir dizi php aracılığıyla döngü] (içinde
İlgili konular