I am using Server-To-Server OAuth App
Trying to schedule the zoom meeting URL but getting following error. I have added necessary Scopes as well.
Here is the code which i follow and using composer require guzzlehttp/guzzle for this :
<?php
require 'vendor/autoload.php'; // Include the Guzzle library
// Zoom API credentials
$clientId = 'YOUR_CLIENT_ID';
$clientSecret = 'YOUR_CLIENT_SECRET';
// Define the API endpoint to create a meeting
$apiEndpoint = 'https://api.zoom.us/v2/users/YOUR_USER_ID/meetings';
// Define the meeting data
$meetingData = [
'topic' => 'Sample Meeting',
'type' => 2, // 2 for a scheduled meeting
'start_time' => '2023-09-15T14:00:00Z', // Set your desired start time in UTC
'duration' => 60, // Meeting duration in minutes
'timezone' => 'UTC',
];
// Generate a JWT token for Server-to-Server OAuth
$tokenUrl = 'https://zoom.us/oauth/token';
$tokenPayload = [
'grant_type' => 'client_credentials',
'client_id' => $clientId,
'client_secret' => $clientSecret,
];
$tokenHeaders = [
'Content-Type' => 'application/x-www-form-urlencoded',
];
$tokenClient = new \GuzzleHttp\Client();
$response = $tokenClient->post($tokenUrl, [
'form_params' => $tokenPayload,
'headers' => $tokenHeaders,
]);
$tokenData = json_decode($response->getBody(), true);
if (isset($tokenData['access_token'])) {
// Use the access token to create a meeting
$meetingHeaders = [
'Authorization' => 'Bearer ' . $tokenData['access_token'],
'Content-Type' => 'application/json',
];
$meetingClient = new \GuzzleHttp\Client();
$meetingResponse = $meetingClient->post($apiEndpoint, [
'headers' => $meetingHeaders,
'json' => $meetingData,
]);
$meetingResult = json_decode($meetingResponse->getBody(), true);
if (isset($meetingResult['id'])) {
echo 'Meeting created successfully. Meeting ID: ' . $meetingResult['id'];
} else {
echo 'Error creating meeting: ' . json_encode($meetingResult);
}
} else {
echo 'Error obtaining access token: ' . json_encode($tokenData);
}
Or can any one give simple solution to create meeting using PHP? Any reference would be great.