小编Hyb*_*rid的帖子

在php中为curl设置"--kealalive-time"

一些背景故事:https: //serverfault.com/questions/714273/curl-returning-error-52-or-56-with-rest-api-call-spanning-more-than-5-minutes

所以,我需要通过PHP进行这个REST API调用,并且我可以通过CLI让它工作的唯一方法是--keepalive-time为CURL 设置.那么我该如何在PHP中做到这一点?以下是直接通过CURL进行的(通过删除审讯)工作API调用:

curl --max-time 600 -k -o dump.txt --connect-timeout 0 --keepalive-time 30 --trace-ascii trace.txt --trace-time -X GET -H "tenant-code: 1cmPx7tqVDVTdN1GSelwycFUmICmASnLCmNQsV72" -H "Authorization: Basic JxHAsXeUiHMRkS8Msiu6pWb3PvY20p6am3QvXCY3knXTAntlxTBS3EyEDgly" -H "Content-Type: application/json" -H "Cache-Control: no-cache" 'https://api.endpoint.com/API/v1/system/users/search?groupid=555'
Run Code Online (Sandbox Code Playgroud)

--max-time--connect-timeout值似乎并没有那么多(只要他们是我所需要的范围内),但到物质--keepalive-time似乎需要得到的数据,从回调.这是我正在使用的一些测试代码:

<?php
$url = "https://api.endpoint.com/API/v1/system/users/search?groupid=555";
$session = curl_init($url);
curl_setopt($session,CURLOPT_RETURNTRANSFER, true);
curl_setopt($session,CURLOPT_TIMEOUT, 600);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session, CURLOPT_AUTOREFERER, true);
curl_setopt($session, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($session, CURLOPT_VERBOSE, true);
curl_setopt($session, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($session, CURLOPT_NOPROGRESS, false); 
curl_setopt($session, CURLOPT_FORBID_REUSE, true);
curl_setopt($session, CURLOPT_FRESH_CONNECT, true); …
Run Code Online (Sandbox Code Playgroud)

php curl

6
推荐指数
1
解决办法
2707
查看次数

标签 统计

curl ×1

php ×1