I use sample code for PHP how ever after upload image to server. Anyone can help?

$url = 'http://cloud.ocrsdk.com/processImage?language=english&exportFormat=rtf';

// Send HTTP POST request and ret xml response
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt ($curlHandle, CURLOPT_CONNECTTIMEOUT, 20 );
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlHandle, CURLOPT_USERPWD, "$applicationId:$password");
curl_setopt($curlHandle, CURLOPT_POST, 1);
curl_setopt($curlHandle, CURLOPT_USERAGENT, "PHP Cloud OCR SDK Sample");
$post_array = array(
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $post_array); 
$response = curl_exec($curlHandle);

$response is empty.

asked 23 May '13, 21:40

mynigo's gravatar image


edited 24 May '13, 19:05

Dmitry%20Me's gravatar image

Dmitry Me ♦♦

This code snippet is from PHP sample on Github:

$response = curl_exec($curlHandle);
if($response == FALSE) {
  $errorText = curl_error($curlHandle);

Note the if($response == FALSE) { check - in case of error $response will be set to FALSE and if you echo it you indeed see empty output.

So the bottom line is you have to handle this case in a manner similar to how it is handled in the sample - anticipate FALSE and call curl_error() to obtain error details.


answered 24 May '13, 19:12

Dmitry%20Me's gravatar image

Dmitry Me ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 23 May '13, 21:40

Seen: 895 times

Last updated: 24 May '13, 19:12

© 2016 ABBYY. All rights Reserved. www.ABBYY.com | Privacy Policy | Legal