Reputation: 1
I'm not able to generate meet link from GSUIT service account for the google calendar api from the following code. I am getting this error when i run this function
Error:
Fatal error: Uncaught Google\Service\Exception: { "error": { "errors": [ { "domain": "global", "reason": "invalid", "message": "Invalid conference type value." } ], "code": 400, "message": "Invalid conference type value." } } in D:\xampp\htdocs\projects\serviceaccount\vendor\google\apiclient\src\Http\REST.php:128 Stack trace: #0 D:\xampp\htdocs\projects\serviceaccount\vendor\google\apiclient\src\Http\REST.php(103): Google\Http\REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google\Service\...') #1 [internal function]: Google\Http\REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google\Service\...') #2 D:\xampp\htdocs\projects\serviceaccount\vendor\google\apiclient\src\Task\Runner.php(182): call_user_func_array(Array, Array) #3 D:\xampp\htdocs\projects\serviceaccount\vendor\google\apiclient\src\Http\REST.php(66): Google\Task\Runner->run() #4 D:\xampp\htdocs\projects\serviceaccount\vendor\google\apiclient\src\Client.php in D:\xampp\htdocs\projects\serviceaccount\vendor\google\apiclient\src\Http\REST.php on line 128
Code:
<pre>
$client = new Google\Client();
$client->setAuthConfig($jsonKey);
$client->setScopes(['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.events','https://www.googleapis.com/auth/admin.reports.audit.readonly']);
$client->setSubject('[email protected]');
$client->setAccessType('offline');
$cal_id = '[email protected]';
$calendarService = new Google\Service\Calendar($client);
$event = new Google\Service\Calendar\Event(array(
'summary' => 'test link generate', //'Google Calendar ',
'description' => 'Book Room', //'Book Room',
'start' => array(
'dateTime' => '2021-07-17T00:50:00+05:30',//'2018-08-16T14:30:00-00:00',
'timeZone' => 'Asia/Kolkata',
),
'end' => array(
'dateTime' => '2021-07-17T00:55:00+05:30',//'2018-08-16T14:30:00-01:00',
'timeZone' => 'Asia/Kolkata',
),
'reminders' => array(
'useDefault' => FALSE,
'overrides' => array(
array('method' => 'popup', 'minutes' => 10),
),
),
'conferenceData' => array(
'createRequest' => array(
'conferenceSolutionKey' => array(
'type' => 'hangoutsMeet'
),
'requestId' => 'ADGGSH'. time()
)
)
));
$createdEvent = $calendarService->events->insert($cal_id, $event, array('conferenceDataVersion' => 1));
</pre>
I'm getting following error with this code, But without adding (ConferenceData property and setting conferenceDataVersion = 1) i'm able to create event without the hangout link
Resource:
https://github.com/googleapis/google-api-php-client composer require google/apiclient:^2.10
Upvotes: 0
Views: 1022
Reputation: 1
$client = new Google\Client();
$client->setAuthConfig($jsonKey);
$client->setScopes(['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.events','https://www.googleapis.com/auth/admin.reports.audit.readonly']);
$client->setSubject('[email protected]'); //This is my GSUIT service account(client email) created which is impersonating(linked to my personal GSUIT email)
$client->setAccessType('offline');
$cal_id = '[email protected]'; //The events created will appear on my GSUIT personal account
$calendarService = new Google\Service\Calendar($client);
$conference = new Google\Service\Calendar\ConferenceData();
$conferenceRequest = new Google\Service\Calendar\CreateConferenceRequest();
$conferenceSolutionKey = new Google\Service\Calendar\ConferenceSolutionKey();
$conferenceSolutionKey->setType("hangoutsMeet");
$conferenceRequest->setRequestId('ADGGSH'. time());
$conferenceRequest->setConferenceSolutionKey($conferenceSolutionKey);
$conference->setCreateRequest($conferenceRequest);
$event = new Google\Service\Calendar\Event(array(
......
'conferenceData' => $conference
));
$createdEvent = $calendarService->events->insert($cal_id, $event, array('conferenceDataVersion' => 1));
Error :
Fatal error: Uncaught Google\Service\Exception: { "error": { "errors": [ { "domain": "global", "reason": "invalid", "message": "Invalid conference type value." } ], "code": 400, "message": "Invalid conference type value." } }
Upvotes: 0
Reputation: 5963
If you will check Google Calendar API PHP reference documentation, Google_Service_Calendar_Events_Resource insert() expects an Google_Service_Calendar_Event object. Where the conferenceData
should be a Google_Service_Calendar_ConferenceData.
$conference = new \Google_Service_Calendar_ConferenceData();
$conferenceRequest = new \Google_Service_Calendar_CreateConferenceRequest();
$conferenceSolutionKey = new \Google_Service_Calendar_ConferenceSolutionKey();
$conferenceSolutionKey->setType("hangoutsMeet");
$conferenceRequest->setRequestId('ADGGSH'. time());
$conferenceRequest->setConferenceSolutionKey($conferenceSolutionKey);
$conference->setCreateRequest($conferenceRequest);
$event->setConferenceData($conference);
or
$event = new Google\Service\Calendar\Event(array(
......
'conferenceData' => $conference
));
Upvotes: 0