1

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

8
  • is CURLOPT_RETURNTRANSFER on? Commented Mar 10, 2011 at 17:01
  • Show some of the curl code. The issue may be a SET_OPT. Commented Mar 10, 2011 at 17:01
  • which php version are you using? Commented Mar 10, 2011 at 17:22
  • I am using php version 5.2.11 Commented Mar 10, 2011 at 17:30
  • 1
    Since it's a GET, what happens if you hit the url directly in a browser? Commented Mar 10, 2011 at 17:37

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Jaitsu - yes my code was working but I was seeing only partial XML due to the limit on error_log - doh!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.