php - php中的异步Curl请求给出了错误的请求
问题描述
使用 PHP 7.3.14 版本在暂存中工作 不适用于生产环境 PHP 7.1.12 Curl 调用响应是 400 错误请求。我的代码
$url = $this->_CI->config->item('app_base_url') . $uri;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'ABODE-API-KEY:' . $this->_key,
// 'Cookie:' . $this->_CI->input->get_request_header('Cookie', true),
// 'X-Device-Id:' . $this->_CI->input->get_request_header($this->_CI->config->item('cookie_device_id_name'), true)
));
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 1);
//curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
if ($method == 'post') {
curl_setopt($curl, CURLOPT_POST, true);
} else if ($method == 'put') {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
} else if ($method == 'delete')
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
else if ($method == 'patch') {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
} else
curl_setopt($curl, CURLOPT_HTTPGET, true);
$response = curl_exec($curl);
if ($rollbar_log === true)
$this->_CI->mlog->critical("Error: Response from asyn curl call URL:" . $url . "KEY:" . $this->_key . " Response:" . print_r($response, true));
if (empty($response)) {
$error = curl_error($curl);
log_message('error', "Error from asyn curl call" . print_r($error, true));
$this->_CI->mlog->critical("Error: asyn curl call " . $this->_key . " Error:" . print_r($error, true));
curl_close($curl);
return;
}
curl_close($curl);
}
获取响应错误请求 400
解决方案
推荐阅读
- mercurial - 如何在合并之前查看完整的功能分支
- cloudant - 由于冲突冲突,Cloudant 创建相同 _id 文档跨数据库失败 文档更新冲突
- d3.js - 使用 d3js 操纵孩子的孩子
- google-apps-script - 如何通过部署为 webapp 的谷歌应用脚本触发 powershell 脚本?
- javascript - 如何在jquery中按特定顺序对对象数组进行排序
- html - 如何删除引导程序 4 中链接元素和切换器之间的间距?
- node.js - NodeJS async.each/parallel 用于动态数组
- c - 1000以下所有3或5的倍数之和在C中给出错误答案
- r - R data.table:使用 %like% 和 setkey
- binary - 这个映射是哪个二进制操作?