동안

2016-06-11 5 views
0

은 사용자가 완벽하게 표시됩니다 허가 & 스크립트가 모든 데이터를 처리 시작할 수 있습니다 때 나는 오류를동안

PHP 공지를 얻을 : 정의되지 않은 인덱스 : GD의 $ 이메일을

에 여기 내 PHP 코드는

if (!empty($contacts['feed']['entry'])) 
    { 
foreach($contacts['feed']['entry'] as $contact) 
    { 

    // retrieve user photo 

    if (isset($contact['link'][0]['href'])) 
     { 
     $url = $contact['link'][0]['href']; 
     $url = $url . '&access_token=' . urlencode($accesstoken); 
     $curl = curl_init($url); 
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
     curl_setopt($curl, CURLOPT_TIMEOUT, 15); 
     curl_setopt($curl, CURLOPT_VERBOSE, true); 
     $image = curl_exec($curl); 
     curl_close($curl); 
     } 


    if ($image === 'Photo not found') 
     { 

     // retrieve Name and email address 

     $return[] = array(
      'name' => $contact['title']['$t'], 
      'email' => $contact['gd$email'][0]['address'], 
      'img_url' => '//cdn.twkcdn.com/profile/image/avatar.png?w=40&h=40&cf', 
     ); 
     } 
     else 
     { 

     // retrieve Name and email address 

     $return[] = array(
      'name' => $contact['title']['$t'], 
      'email' => $contact['gd$email'][0]['address'], 
      'img_url' => $url, 
     ); 
     } 
    } 

$google_contacts = $return; //returning all d 
} 

이 난 이유를 알고하지 않습니다 절반 스크립트 & 단지 예입니다 google에서 연락처를 가져 오는 데 15-20 초 정도 걸립니다.이 페이지를 방문 할 때마다

+1

'은 $ 이메일을 gd 카메라'나는 생각한다 Google은 "gd : email"대신 $ 대신 콜론을 사용합니다. 변수를 문자열에 드롭하려고하면 큰 따옴표를 사용해야하므로 변수가 파싱됩니다. –

답변

0

Google에서 모든 항목에 이메일 주소가 있는지 확인하지 않습니다. immediatly의 Foreach 후

추가 : API의 부르심, 응답에서 추측하기 어려운 될 것 구글의 어떤 주위에, 내가보고 좀 더 자세하게없이

if (!array_key_exists('gd$email', $contact)){ 
    continue; 
}