PHP Invalid Access Token

So I’m using the below code to firstly get an access token…

$clientID="";
$clientSecret="
";
$content = “grant_type=client_credentials&client_id=$clientID&client_secret=$clientSecret”;
$token_url=“https://zoom.us/oauth/token”;

$ch = curl_init($token_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$objJSON = json_decode($result,false);

Which works fine and I get a token back…

$webinarID = “164712960”;
$token_url=“https://api.zoom.us/v2/webinars/”. $webinarID . “/registrants”;
$content ="";
$headers = array(
‘authorization’ => 'Bearer ’ . $objJSON->access_token,
‘content-type’ => ‘application/json’
);

$ch = curl_init($token_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);

However with the above that I am using to register a new attendee (aware I am not passing any content yet) I am getting a {“code”:124,“message”:“Invalid access token.”} response back.

What am I doing wrong?

Hey @TCADeveloper,

Please try passing in a request body (content) and see if that fixes the issue.

Thanks,
Tommy

Hi Tommy,

I’m now passing it the following JSON, and its still returning Invalid.

{“email":"simon@simonhix.co.uk”,“first_name”:“Simon”,“last_name”:“Hix”,“address”:“dsfhkdjsfh st”,“city”:“jackson heights”,“country”:“US”,“zip”:“11371”,“state”:“NY”,“phone”:“00000000”,“industry”:“Food”,“org”:“Cooking Org”,“job_title”:“Cooking Org”,“purchasing_time_frame”:“1-3 months”,“role_in_purchase_process”:“Influencer”,“no_of_employees”:“10”,“comments”:“Looking forward to the Webinar”,“custom_questions”:{“title”:“What do you hope to learn from this Webinar?”,“value”:“Look forward to learning how you come up with new recipes and what other services you offer.”}}

Simon

Hey @TCADeveloper,

Thanks, can you private message me your access token so I can take a look?

Thanks,
Tommy