php - 致命错误:未捕获的 Requests_Exception:cURL 错误 28:连接在 10009 毫秒后超时
问题描述
我尝试运行用 PHP 编写的第三方 API,但是当我尝试运行时,它给了我一个错误
致命错误:未捕获的 Requests_Exception:cURL 错误 28:连接在 D:\xampp\htdocs\ArchivLearn\Requests\library\Requests\Transport\cURL.php:428 10009 毫秒后超时 堆栈跟踪:#0 D:\xampp\htdocs \ArchivLearn\Requests\library\Requests\Transport\cURL.php(179):Requests_Transport_cURL->process_response('', Array) #1 D:\xampp\htdocs\ArchivLearn\Requests\library\Requests.php(381): Requests_Transport_cURL->request('http://api-core...', Array, Array, Array) #2 D:\xampp\htdocs\ArchivLearn\po_client.php(54): Requests::request('http: //api-core...', Array, Array, 'POST') #3 D:\xampp\htdocs\ArchivLearn\po_client.php(31): POClient->request('post', '/apps/any /sessi...', Array) #4 D:\xampp\htdocs\ArchivLearn\pet_details.php(12): POClient->sign_in('ka83jf466',Array) #5 {main} 在第 428 行的 D:\xampp\htdocs\ArchivLearn\Requests\library\Requests\Transport\cURL.php 中抛出
public function requestJSON($method, $path, $jsonString) {
$timestamp = $this->timestamp();
$signature = $this->signature($path, $timestamp);
$jsonString = str_replace('{accesskey}', $this->access_key, $jsonString);
$jsonString = str_replace('{timestamp}', $timestamp, $jsonString);
$jsonString = str_replace('{signature}', $signature, $jsonString);
$jsonString = str_replace('{session}', $this->token, $jsonString);
$headers = ['Content-Type' => 'application/json', 'Accept' => '*/*'];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $this->host.$path,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_POSTFIELDS => $jsonString,
CURLOPT_HTTPHEADER => $headers
));
$response = curl_exec($curl);
$err = curl_error($curl);
if ($err) {
error_log("requestJSON error".json_encode($err));
}
if ($response) {
return json_decode($response);
}
return null;
}
请帮我解决这个问题。
解决方案
推荐阅读
- flutter - 在 Flutter 的 ListView 中填充生成的动态数据
- android - 启用 ANDROIDX_TEST_ORCHESTRATOR(1.4.0) 时未找到测试
- docker - 没有连接到 OpenShift 上的 dind 容器来构建 docker 映像
- javascript - VueJS 滑块组件 - 禁用特定范围的值,例如。85-100?
- visual-studio - Visual Studio - 防止创建
和 在 CSPROJ 中移动文件时的标签 - python - 多对多字段表单内联添加、删除和编辑
- javascript - 切换按钮单击时弹出
- validation - 验证指令 INPUT_FIELD_DEFINITION
- python - lambda的2个实现有什么不同
- c - 为什么这个程序在转换后打印 23?