1
votes

I used the code like line 49 to line 54 of this https://code.google.com/p/google-api-php-client/source/browse/trunk/examples/contacts/simple.php But, I got the invalid_grant error. I went to Google APIs Console, I cannot file Google Contacts service to grant.

Please help me.

1
Hi, Did you find any solution?Reza Amya

1 Answers

1
votes

Did you include the proper settings on the following lines? You will need to create the appliation settings at the API Console and then plug those settings into your code below. This code worked perfect for me once all the settings were correct.

$client = new Google_Client();
$client->setApplicationName('Google Contacts PHP Sample');
$client->setScopes("http://www.google.com/m8/feeds/");
// Documentation: http://code.google.com/apis/gdata/docs/2.0/basics.html
// Visit https://code.google.com/apis/console?api=contacts to generate your
// oauth2_client_id, oauth2_client_secret, and register your oauth2_redirect_uri.
// $client->setClientId('insert_your_oauth2_client_id');
// $client->setClientSecret('insert_your_oauth2_client_secret');
// $client->setRedirectUri('insert_your_redirect_uri');
// $client->setDeveloperKey('insert_your_developer_key');