I have been working on a Laravel project that provides online education to students. I wanted to use ZOOM services of video conferencing so that teacher can connect with his students through video conference. Following the API reference documentation, I have registered an app with zoom. I got API key and API secret along with an access token by following the documentation.
I am sending subsequent requests to post/fetch data from zoom, but I have been getting an error message like this.
Client error: POST https://api.zoom.us/v2/accounts
resulted in a 400 Bad Request
response: {“code”:200,“message”:“Invalid api key or secret.”}
I am sending API key and API secret in header but still getting the same error. Probably I am doing something wrong with the requesting process or may be something else, I don’t know. I have searched on internet how to integrate zoom with Laravel app but couldn’t found any helpful information.
Can anybody please help me to figure out what I am doing wrong? Can someone provide me some helpful resources about zoom API integration with Laravel?
My code:
$client_id = env('CLIENT_ID');
$client_secret = env('CLIENT_SECRET');
$content = "grant_type=client_credentials&client_id=$client_id&client_secret=$client_secret";
$token_url="https://zoom.us/oauth/token";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $token_url,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $content
));
$data = curl_exec($curl);
curl_close($curl);
$result = json_decode($data);
$access_token = $result->access_token;
$client = new \GuzzleHttp\Client();
$api_key = env('API_KEY');
$api_secret = env('API_SECRET');
$response = $client->request('POST', 'https://api.zoom.us/v2/accounts', [
'headers' => [
'apikey' => $api_key,
'apisecret' => $api_secret,
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Bearer '. $access_token
],
'form_params' => [
'first_name' => $request->first_name,
'last_name' => $request->last_name,
'email' => $request->email,
'password' => $request->password,
],
]);
$response = $response->getBody()->getContents();
dd($response);
}