Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php卷曲返回大小增加_Php_Curl - Fatal编程技术网

php卷曲返回大小增加

php卷曲返回大小增加,php,curl,Php,Curl,我目前正在通过运行cURL代理端点,但是我的cURL的大小大约是原始API的10倍,这是为什么,我如何减小大小?这都是JSON BTW 原始API返回大小=32.2kb cURL return size=488KB 这是我的卷曲脚本: $ch = curl_init(); // set url $url = 'http://domain.com/api/v1'; // set options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($c

我目前正在通过运行cURL代理端点,但是我的cURL的大小大约是原始API的10倍,这是为什么,我如何减小大小?这都是JSON BTW

原始API返回大小=32.2kb
cURL return size=488KB

这是我的卷曲脚本:

$ch = curl_init();
// set url
$url = 'http://domain.com/api/v1';

// set options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_setopt($ch, CURLOPT_ENCODING,  '');
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);

// close curl resource to free up system resources
curl_close($ch);
return $output;
ob_start('ob_gzhandler')

php输出缓冲区控件是解决我问题的方法。谢谢你的帮助

嗯,我想知道<代码>curl_setopt($ch,CURLOPT_编码,“gzip”)curl_setopt($ch,CURLOPT_ENCODING,“gzip”)
可以在3/4的时间内减少下载量(刚刚测试过)。请对试图帮助你的人温和一点。@pedrobito原始api返回值是32.2kb,当我卷曲它时,返回值是488kb。我的问题是为什么它会这么大?如何减小大小以反映真实api返回的大小?我没有向它添加任何数据。