2017-07-12 12 views
0

での作業:PHPのGoogle APIの連絡PHPの403、私は、ユーザーの連絡先を取得するには、GoogleのREST APIエンドポイントを照会する郵便配達員

public static function getContacts(string $token) { 
     $url = "https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=999999"; 
     $opts = [ 
      "http" => [ 
       "method" => "GET", 
       "header" => "Authorization: Bearer {$token}" 
      ] 
     ]; 
     $response = file_get_contents($url, false, stream_context_create($opts)); 
     $contacts = json_decode($response); 
     return $contacts; 
    } 

はしかし、要求は403にもトークンが有効と要求であると思っ返します郵便配達員を介して送信するときに機能します。

+0

トークンは正しいですか?エラー403は、あなたのトークンが要求されたリソースにアクセスできないことを意味します。郵便配達員と一緒に送ってきたリクエストは何ですか?それも投稿してください。 –

答えて

1
Use curl to call api. i think it will work fine there. 
関連する問題