The problem is that I cannot communicate with the ZOOM server using cURL, because when executing the code it throws the error:
api_key=zo6vnIDiTD6sN2fuQ7hGrA&api_secret=Z9iiHMSL6CEt35IVk9Z3MDYP0jWKZRR&data_type=JSON&userId=teacher%40bitbcn.orgstring(46) "{"code":124,"message":"Invalid access token."}"
I get this message after applying a var_dump()
to my array
server response container.
function getGrabacionesZOOM(){
$request_url = $this->url;
/*Adds the Key, Secret, & Datatype to the passed array*/
$data['api_key'] = $this->api_key_ZOOM;
$data['api_secret'] = $this->api_secret_ZOOM;
$data['data_type'] = 'JSON';
$data['userId']= '[email protected]';
$postFields = http_build_query($data);
/*Check to see queried fields*/
/*Used for troubleshooting/debugging*/
echo $postFields;
/*Preparing Query...*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//variable contenedora de la respuesta
$response = curl_exec($ch);
var_dump($response);
curl_close($ch);
}
This code should be able to get this response and then start parsing the array
.
{
"from": "string [date]",
"to": "string [date]",
"page_count": "integer",
"page_size": "integer",
"total_records": "integer",
"next_page_token": "string",
"meetings": [
{
"uuid": "string",
"id": "string",
"account_id": "string",
"host_id": "string",
"topic": "string",
"start_time": "string [date-time]",
"duration": "integer",
"total_size": "string",
"recording_count": "string",
"recording_files": [
{
"id": "string",
"meeting_id": "string",
"recording_start": "string",
"recording_end": "string",
"file_type": "string",
"file_size": "number",
"play_url": "string",
"download_url": "string",
"status": "string",
"deleted_time": "string",
"recording_type": "string"
}
]
}
]
}
As the documentation indicates and most of the code I got from a github example
The problem is how you are making the request to the server with cURL from PHP.
In fact, the communication with the ZOOM server is correct, the problem is that you are not sending the parameters required by ZOOM.
According to the documentation, you should send a token through
headers
the HTTP request as follows:And as a mandatory parameter through the url you must send the
userId
There are other parameters, which are not mandatory but you could send them via the URL.
The request you make with cURL is not correct. Firstly, at no time do you send the token in the headers (you don't even send headers), and secondly, I risk saying that
userId
it is not an email.The first thing you have to do is get your token through a POST type request and thus be able to make more requests, here in the documentation you can find how to do it.
When you make the request to make the token, it will return the following information in JSON format:
In this case, what interests us is the access_token , once we have it, we must get the userId , the user ID you can get in the request to get all users called list users .
List users returns the following JSON format.
Once we have the access_token and the userId, we can make the request to obtain the recordings of that user through PHP cURL.