我想使用 zoom API 创建 zoom 用户,这在我的代码中使用版本 1 zoom API 但在 zoom 于 2020 年 4 月更改其 API 后,我遇到了一些问题。请在下面找到我的两个 API 代码对于迁移我正在关注这个博客:点击这里
用于将缩放 API 版本 1 迁移到版本 2 的代码
版本 1 代码:
function createAUser() {
$createAUserArray = array();
$createAUserArray['email'] = $_POST['userEmail'];
$createAUserArray['type'] = $_POST['userType'];
return $this->sendRequest( 'user/create', $createAUserArray );
}
/*Functions for management of users*/
function sendRequest( $calledFunction, $data ) {
/*Creates the endpoint URL*/
$request_url = $this->api_url . $calledFunction;
/*Adds the Key, Secret, & Datatype to the passed array*/
$data['api_key'] = $this->api_key;
$data['api_secret'] = $this->api_secret;
$data['data_type'] = 'JSON';
$postFields = http_build_query( $data );
/*Check to see queried fields*/
/*Used for troubleshooting/debugging*/
if ( $this->debug ) {
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 );
$response = curl_exec( $ch );
/*Check for any errors*/
$errorMessage = curl_exec( $ch );
if ( $this->debug ) {
echo $errorMessage; die();
}
curl_close( $ch );
/*Will print back the response from the call*/
/*Used for troubleshooting/debugging */
if ( $this->debug ) {
echo $request_url;
var_dump( $data );
var_dump( $response );
}
if ( ! $response ) {
return false;
}
return $response;
/*Return the data in JSON format*/
//return json_encode($response);
}
版本 2 代码:
$curl = curl_init();
$postData = [
'action'=> 'create',
'email'=> 'abc@gmail.com',
'type'=> 1,
'first_name'=> 'Haku',
'last_name'=> 'Dhakhada'
];
curl_setopt_array($curl, array(
CURLOPT_POST => true,
CURLOPT_URL => "https://api.zoom.us/v2/users/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS, json_encode($postData),
CURLOPT_HTTPHEADER => array(
"authorization: Bearer Key",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
zoom api 版本 2 代码中的错误:
<error>
<code>300</code>
<message>Request Body should be a valid JSON object.</message>
</error>
提前致谢