1
votes

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.

Does anyone know the cause of this?

Code is as follows:

       $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);

Thanks, Mark

1
is CURLOPT_RETURNTRANSFER on? - KJYe.Name 葉家仁
Show some of the curl code. The issue may be a SET_OPT. - Belinda
which php version are you using? - KJYe.Name 葉家仁
I am using php version 5.2.11 - miller_121
Since it's a GET, what happens if you hit the url directly in a browser? - Marc B

1 Answers

1
votes

It looks like you're using the error_log function to save your response to the error log.

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.