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 'GooglePeople' ... Stack trace: #0 {main} thrown in #1

Closed
lrcvrino opened this issue Feb 27, 2018 · 4 comments

Comments

@lrcvrino
Copy link

My php file show the next error:
Fatal error: Uncaught Error: Class 'GooglePeople' not found in /var/www/html/gcontacts/index.php:5 Stack trace: #0 {main} thrown in /var/www/html/gcontacts/index.php on line 5

index.php code:
require_once __DIR__ . '/vendor/autoload.php'; $people = new GooglePeople($GoogleOAuth2Handler);

php.ini display_errors are On

I do some wrong, please help!

@DivineOmega
Copy link
Member

You need to use the GooglePeople class. Just add the following line before you create a new GooglePeople object.

use RapidWeb\GooglePeopleAPI\GooglePeople;

Also, make sure you've gone through the setup section of the readme. :)

@DivineOmega
Copy link
Member

Did you manage to get this working?

@DivineOmega
Copy link
Member

Ah. I see you just opened #2. I'll take a look.

@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