php - 为什么我在向 REST API 发出 HTTP 请求时收到“502 状态错误”?
问题描述
我正在尝试从 REST API 获取一些数据,我已经正确指定了参数,甚至我的访问令牌也是有效的,但我没有得到预期的响应,我正在发出以下 HTTP 请求:
//set parameters
$paramRequest = array(
"title" => "Sample Daily meeting",
"agenda" => "Sample Agenda",
"password" => "BgJep@43",
"start" => "2020-07-01 15:00:00",
"end" => "2020-07-01 16:00:00",
"timezone" => "Asia/Shanghai",
"recurrence" => "FREQ=DAILY;INTERVAL=1;COUNT=10",
"enabledAutoRecordMeeting" => false,
"allowAnyUserToBeCoHost" => false,
);
$cURLConnection = curl_init("https://webexapis.com/v1/meetings");
curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, $paramRequest);
curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURLConnection, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
'Connection: Keep-Alive',
'Authorization: Bearer ' . $token
));
//send HTTP POST request
$apiResponse = curl_exec($cURLConnection);
curl_close($cURLConnection);
// $apiResponse - available data from the API request
$jsonArrayResponse = json_decode($apiResponse);
//display response
print_r($jsonArrayResponse);
我从 API 收到以下响应:
stdClass Object ( [message] => The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request. [errors] => Array ( [0] => stdClass Object ( [description] => The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request. ) ) [trackingId] => ROUTER_5EFC3CCD-C466-01BB-0100-AC12DED20100 )
解决方案
推荐阅读
- flutter - 颤振中的共享偏好在 pub get 上给出错误
- react-native - 在 FlatList 中使用时,可选文本不起作用
- scala - 线程“主”java.lang.NoClassDefFoundError 中的 Gatling 错误异常:io/gatling/charts/component/impl/ComponentLibraryImpl
- javascript - 如何使用jquery查找和删除数组
- php - foreach 在 foreach 检查数据?
- python - concurrent.futures:如何在 2 个单独的线程中提交任务和处理 Futures?
- python - Selenium webdriver在python中的chrome编码中打开一个新选项卡
- python - 数据传入时更新 json 文件的最佳方法
- php - 在重复密钥更新时……时间戳未更新
- flutter - 如何在颤振(android)中制作这个自定义应用栏?