Hello,
I'm working on you BusinessCardProcess API. It's Very nice API and quick Response.
I use this API in CURL request and pass the imageSource and exportFormat but every time response is given 551 (Unsupported image file format).
I was tried to pass the image as an image file data format and JSON format place both the code in below.
Image File Data:
$business_card_front_image_pic = $request->file('business_card_front_image_pic');
$appName = env('ABBYY_APP_NAME');
$appPassword = env('ABBYY_PASSWORD');
$apiUrl = 'https://cloud.ocrsdk.com/processBusinessCard';
$requestBody = array();
$requestBody['imageSource'] = $business_card_front_image_pic;
$requestBody['exportFormat'] = 'xml';
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, $apiUrl);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($connection, CURLOPT_USERPWD, "$appName:$appPassword");
curl_setopt($connection, CURLOPT_POST, true);
curl_setopt($connection, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($connection, CURLOPT_HTTPHEADER, array('Content-Type: image/jpeg'));
curl_setopt($connection, CURLOPT_POSTFIELDS, json_encode($requestBody));
$result = curl_exec($connection);
Image JSON pass in request:
$business_card_front_image_pic = $request->file('business_card_front_image_pic');
$front = base64_encode(file_get_contents($business_card_front_image_pic));
$appName = env('ABBYY_APP_NAME');
$appPassword = env('ABBYY_PASSWORD');
$apiUrl = 'https://cloud.ocrsdk.com/processBusinessCard';
$requestBody = array();
$requestBody['imageSource'] = $front;
$requestBody['exportFormat'] = 'xml';
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, $apiUrl);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($connection, CURLOPT_USERPWD, "$appName:$appPassword");
curl_setopt($connection, CURLOPT_POST, true);
curl_setopt($connection, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($connection, CURLOPT_HTTPHEADER, array('Content-Type: image/jpeg'));
curl_setopt($connection, CURLOPT_POSTFIELDS, json_encode($requestBody));
$result = curl_exec($connection);