Using Server to Server App Credentials here:
use App\Http\Controllers\Controller;
use GuzzleHttp\Client as GHttp;
use GuzzleHttp\Psr7\Request as GRequest;
// access token
$url = env('ZOOM_API_URL');
$basic_auth = new GHttp(['base_uri' => $url]);
$account_id = env('ZOOM_ACCOUNT_ID');
$client_id = env('ZOOM_CLIENT_ID');
$client_secret = env('ZOOM_CLIENT_SECRET');
$credentials = base64_encode($client_id . ':' . $client_secret);
$meeting_id = '';
$access_token = '';
$zak_token = '';
$user_id = ''; // add your user id
$response = $basic_auth->post(
'oauth/token',
[
'headers' =>
[
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic ' . $credentials,
],
'form_params' => [
"grant_type" => "account_credentials",
"account_id" => $account_id
]
]
)->getBody()->getContents();
$json_response = json_decode($response);
$access_token = $json_response->access_token;
//get zak token, if needed
$zak_url = $url . 'v2/users/' . $user_id . '/token/?type=zak';
$headers = ['headers' =>,
[
'Authorization' => 'Bearer ' . $access_token
]];
$request = new GRequest('GET', $zak_url);
$response = $basic_auth->send($request, $headers)->getBody()->getContents();
$json_response = json_decode($response);
$zak_token = $json_response->token;
create meeting
$response = $basic_auth->post(
'/v2/users/' . $user_id . '/meetings',
[
'headers' =>
[
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $access_token,
],
'json' => [
'topic' => 'My Topic',
'type' => 1,
'agenda' => '',
'settings' => [
'waiting_room' => false,
'host_video' => true,
'participant_video' => true,
'join_before_host' => true,
'mute_upon_entry' => true,
'approval_type' => 0,
'auto_recording' => 'cloud'
]
]
]
)->getBody()->getContents();
$meeting_json_response = json_decode($response);
// get user details if needed
$user_details = $basic_auth->get(
'v2/users/' . $user_id,
[
'headers' =>
[
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Bearer ' . $access_token,
]
]
)->getBody()->getContents();
dd($user_details);