PHP curl_exec返回部分响应 [英] PHP curl_exec returning partial response
问题描述
我设置了一个php程序,使用curl调用RESTful Web服务,并返回格式正确的XML。当我在命令行上这样做,我得到正确的响应,但当我在PHP使用 curl_exec()
这样做只有大约一半的响应。反应基本上缩短了。
I have set up a php program that calls a RESTful web service using curl and gets back well-formed XML. When I do this on th e command line and I get the correct response but when I do this in PHP using curl_exec()
I only get about half of the response. The response is basically cut short.
有没有人知道原因?
代码如下:
$url = $this->dspace_url . '/dspace/search.xml?query=' . urlencode($query);
$sac_curl = curl_init();
error_log('query url is'.$url);
curl_setopt($sac_curl, CURLOPT_HTTPGET, true);
curl_setopt($sac_curl, CURLOPT_URL, $url);
curl_setopt($sac_curl, CURLOPT_VERBOSE, true);
curl_setopt($sac_curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($sac_curl, CURLOPT_HEADER, false);
$resp = curl_exec($sac_curl);
error_log('response is '.$resp);
感谢,
标记
推荐答案
看起来您正在使用 error_log
函数来保存对错误日志的响应。
It looks like you're using the error_log
function to save your response to the error log.
这似乎有一个限制(默认为1024字节),但您可以使用 log_errors_max_len
属性在php.ini文件中更改它。请尝试将其设置为较大的值,看看是否有任何差异。
There seems to be a limit on this (defaults to 1024 bytes) but you can change it in your php.ini file using the log_errors_max_len
attribute. Try setting that to something larger and see if you find any difference.
这篇关于PHP curl_exec返回部分响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!