How we send data to api from PHP?


#1

Hi I am trying to add a webinar registrant from API but it’s not accepting data and return

stdClass Object ( [code] => 300 [message] => Unsupported Content Type )

THIS CODE IS RUNNING IN PHP

function addWebinarReg($webinarID, $email, $firstName, $lastName) {
$regData = array(
“email” => $email,
“first_name” => $firstName,
“last_name” => $lastName
);

$jsonStrReg = json_encode($regData);
$httpStrReg = http_build_query($regData);

$ch = curl_init(‘https://api.zoom.us/v2/webinars/’.$webinarID.’/registrants’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $httpStrReg);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ’ . generateJWT()
));

$response = curl_exec($ch);
$response = json_decode($response);
curl_close($ch);
return $response;
}

What are the way to send data to body FROM PHP?


#2

You can refer to https://zoom.github.io/api/#add-a-webinar-registrant  and check body arguments with JSON format


#3

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ’ . generateJWT(),

“Content-Type: application/json” 
));

 

From the error message, try adding the content type that you are passing.