我想使用缩放API创建一个网络研讨会事件,我在json_encode中使用php和格式json创建body数据,但当我发送POST到缩放API时,它不起作用。结果总是这样:
[
[code] => 300
[message] => Request Body should be a valid JSON object.
]
这是我在控制器中的代码:
$id = Yii::$app->request->get('id');
$bodyparam = [
"topic" => "test webinar",
"type" => 5,
"start_time" => "2021-10-02T16:00:00Z",
"duration" => 60,
"timezone" => "Asia/Singapore",
"password" => "test123456",
"agenda" => "Test Webinar",
"recurrence" => [
"type" => 1,
"repeat_interval" => 1,
"end_date_time" => "2021-10-02T16:00:00Z"
],
"settings" => [
"host_video" => true,
"panelists_video" => true,
"practice_session" => true,
"hd_video" => true,
"approval_type" => 0,
"registration_type"=> 2,
"audio" => "both",
"auto_recording" => "none",
"enforce_login" => false,
"close_registration" => true,
"show_share_button" => true,
"allow_multiple_devices" => false,
"email_language" => "en-US",
"panelists_invitation_email_notification" => true,
"registrants_confirmation_email" => true,
"registrants_email_notification" => true,
"attendees_and_panelists_reminder_email_notification" => [
"enable" => true,
"type" => 1
],
"follow_up_attendees_email_notification" => [
"enable" => true,
"type" => 1
],
"follow_up_absentees_email_notification" => [
"enable" => true,
"type" => 1
]
]
];
//using json_decode and double encode because if i just encode once the result always string
$body = json_encode(json_decode(json_encode($bodyparam)), JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
$response = Yii::$app->zoom->doRequest('POST','/users/'.$id.'/webinars',['status'=>'active'], $body);
echo "<pre>";print_r($response);exit;
我使用skwirrel缩放api包装器来帮助我创建这个事件。有什么问题吗?
根据文档,您必须传递一个数组作为doRequest()
方法的第三个参数。不是JSON字符串。
$response = $zoom->doRequest(<METHOD>, <endpoint_path> [,<query_parameter_array> [,<path_parameter_array> [,<request_body_array_or_string>] ] ]);
简化:
$params = [,<path_parameter_array> [,<request_body_array_or_string>] ] ];
$response = $zoom->doRequest('METHOD','ENDPOINT_PATH',$params);
看一下这个例子。