Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Uncaught Error: Class 'GoogleOAuth2Handler' not found #2

Closed
lrcvrino opened this issue Feb 28, 2018 · 2 comments
Closed

Comments

@lrcvrino
Copy link

Sorry again,

require_once __DIR__ . '/vendor/autoload.php';

use RapidWeb\GooglePeopleAPI\GooglePeople;

$clientId     = '65blablablablablacbn.apps.googleusercontent.com';
$clientSecret = 'fcblablablablab4lX';
$refreshToken = '1/blablablablalbalblablbalbalbablabla2V';
$scopes       = ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/contacts', 'https://www.googleapis.com/auth/contacts.readonly'];

$googleOAuth2Handler = new GoogleOAuth2Handler($clientId, $clientSecret, $scopes, $refreshToken);

This php code show me that error:
Fatal error: Uncaught Error: Class 'GoogleOAuth2Handler' not found in ... Stack trace: #0 {main} thrown in

@DivineOmega
Copy link
Member

This is similar issue.

You should just be able to add use RapidWeb\GoogleOAuth2Handler\GoogleOAuth2Handler; below your other use ... line.

@lrcvrino
Copy link
Author

lrcvrino commented Mar 1, 2018

@DivineOmega , I am very grateful for your time and help. I have solved it following your instructions. Again, thank you very much. This is the php code that works perfectly:

require_once __DIR__ . '/vendor/autoload.php';

use RapidWeb\GooglePeopleAPI\GooglePeople;
use RapidWeb\GoogleOAuth2Handler\GoogleOAuth2Handler;

$clientId     = '65...n.apps.googleusercontent.com';
$clientSecret = 'fc...X';
$refreshToken = '1...2V';
$scopes       = ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/contacts', 'https://www.googleapis.com/auth/contacts.readonly'];

$googleOAuth2Handler = new GoogleOAuth2Handler($clientId, $clientSecret, $scopes, $refreshToken);
$people = new GooglePeople($googleOAuth2Handler);

// Retrieval all contacts
foreach($people->all() as $contact) {
   echo $contact->resourceName.' - ';
   if ($contact->names) {
       echo $contact->names[0]->displayName . "<br>";
   }
   echo PHP_EOL;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants