Open Defiant74 opened 5 years ago
Hello!
I found the solution.
I forgot to add use RapidWeb\GooglePeopleAPI\Contact
Best regards, Arno.
can you share full script how to create new contact
require_once './vendor/autoload.php';
use RapidWeb\GoogleOAuth2Handler\GoogleOAuth2Handler;
use RapidWeb\GooglePeopleAPI\GooglePeople;
use RapidWeb\GooglePeopleAPI\Contact;
$clientId = 'XX';
$clientSecret = 'XX';
$refreshToken = 'XX';
$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);
$contact = new Contact($people);
$contact->names[0] = new stdClass;
$contact->names[0]->givenName = 'Testy 2';
$contact->names[0]->familyName = 'McTest Test 2';
$contact->save();
Hello!
I wrote a script where Retrieving and Updating Contacts is working perfect. The only thing I'm not able to do, is adding a new contact.
I am using it this way as shown in your documentation: // Create new contact $contact = new Contact($people); $contact->names[0] = new stdClass; $contact->names[0]->givenName = 'Testy'; $contact->names[0]->familyName = 'McTest Test'; $contact->save();
The error message is always the following:
Fatal error: Uncaught Error: Class 'Contact' not found in /var/www/html/googlecontacts/google-contacts.php:34 Stack trace: #0 {main} thrown in /var/www/html/googlecontacts/google-contacts.php on line 34
I have added the script.
Thank you very much for your help! Arno.
google-contacts.txt