私のプロジェクトにGoogle Oauth2を実装したいと思います。私の主な目標は、プロファイル情報を表示するためにgoogle-people APIにアクセスし、googleドライブを使用することです。google-people APIにアクセスするときにプロフィールデータにアクセスできません
私はこれで新しくなったので、いくつかのAPIを有効にしました。ほとんどの場合、情報を取得するのに成功しました。私の問題を引き起こしているのはPeople APIだけですが、私は理由を知りません。ここに私がやっていることがあります(私はすべてのログイン部分をスキップしています)。
スコープの定義:
$client->addScope("https://www.googleapis.com/auth/drive");
$client->addScope("https://www.googleapis.com/auth/youtube");
$client->addScope("https://www.googleapis.com/auth/contacts"); // this is google-people API
$client->addScope("https://www.googleapis.com/auth/plus.login");
$client->addScope("https://www.googleapis.com/auth/userinfo.email");
$client->addScope("https://www.googleapis.com/auth/gmail.readonly");
を
$dr_service = new Google_Service_Drive($client);
$yt_service = new Google_Service_YouTube($client);
$ppl_service = new Google_Service_People($client);
$plus_service = new Google_Service_Plus($client);
$gmail_service = new Google_Service_gmail($client);
作るリクエスト
$dr_results = $dr_service->files->listFiles(array('pageSize' => 10)); //returns a list of files
$yt_response= $yt_service->search->listSearch('id,snippet', array('maxResults' => 25, 'q' => 'yoda', 'type' => ''));//returns videos of Yoda
$plus_results = $plus_service->people->get('me'); // returns my Google+ profile
$gmail_results = $gmail_service->users->getProfile('me'); //returns my Gmail profile
$ppl_results = $ppl_service->people->get('people/me', array('personFields' => 'names,emailAddresses')); //Error
あなたが見ることができるように、4〜5のうちの要求が作業しているAPIを呼び出します。唯一の人々の要求は失敗し、次のメッセージを返している:私は理解していない
Fatal error: Uncaught Google_Exception: (get) unknown parameter: 'personFields' in C:\xampp\htdocs\gLoginPHP\vendor\google\apiclient\src\Google\Service\Resource.php:147 Stack trace: #0 C:\xampp\htdocs\gLoginPHP\vendor\google\apiclient-services\src\Google\Service\People\Resource\People.php(52): Google_Service_Resource->call('get', Array, 'Google_Service_...') #1 C:\xampp\htdocs\gLoginPHP\gLoginPHP.php(81): Google_Service_People_Resource_People->get('people/me', Array) #2 {main} thrown in C:\xampp\htdocs\gLoginPHP\vendor\google\apiclient\src\Google\Service\Resource.php on line 147
一部を、この要求は、私がマニュアルに記載されてい例から正確なコピー/過去であるということである:https://developers.google.com/people/v1/read-people
なぜ誰かが分かりますか?
ありがとうございます!
実際、このGoogle_Service_PeopleServiceは表示されませんでした。このコードを使用すると、私のコードは完全に機能します。 ご協力いただきありがとうございます! 図書館のメンテナーから何が学べるのかを知ることは非常に面白いでしょう。 – Yann