PHP client for connecting to the Robo-Meister FlowScribe OCR API.
composer require robo-meister/flow-scribe-apiFor local development from this repository, add the package as a path repository:
{
"repositories": [
{
"type": "path",
"url": "shared-profile/sdk/flowscribe-ocr/php"
}
],
"require": {
"robo-meister/flow-scribe-api": "*"
}
}use Robo\FlowScribeOcr\FlowScribeOcrClient;
$client = new FlowScribeOcrClient(
baseUrl: 'https://ocr.robo-meister.com'
);
$health = $client->health();
$metadata = $client->metadata();
$result = $client->processDocument(__DIR__ . '/invoice.pdf', [
'document_type' => 'invoice',
'mode' => 'fuse',
'journal_csv' => true,
]);
if (($result['exit_code'] ?? 1) === 0) {
$parsed = $result['parsed'] ?? [];
$csv = $result['csv'] ?? null;
}Pass either a JSON file path:
$result = $client->processDocument(__DIR__ . '/invoice.pdf', [
'config_path' => __DIR__ . '/custom-dictionary.json',
]);Or pass an array that the SDK serializes as config.json for the multipart upload:
$result = $client->processDocument(__DIR__ . '/invoice.pdf', [
'config' => [
'fields' => [
'invoiceNumber' => ['keywords' => ['Invoice #']],
],
],
]);Authenticated integration routes require an access token generated by the Robo Connector link flow. The SDK sends the token as a bearer token.
use Robo\FlowScribeOcr\FlowScribeOcrClient;
$client = new FlowScribeOcrClient(
baseUrl: 'https://ocr.robo-meister.com',
accessToken: getenv('FLOWSCRIBE_ACCESS_TOKEN') ?: null
);
$queued = $client->ingestFlowScribe(__DIR__ . '/invoice.pdf', [
'document_type' => 'invoice',
]);
$jobId = $queued['data']['job']['id'];
$status = $client->flowScribeStatus($jobId);For the RC invoice OCR bridge, use ingestRcInvoice() and rcInvoiceStatus().
HTTP and transport failures throw FlowScribeOcrException:
use Robo\FlowScribeOcr\FlowScribeOcrException;
try {
$result = $client->processDocument(__DIR__ . '/invoice.pdf');
} catch (FlowScribeOcrException $exception) {
$statusCode = $exception->getStatusCode();
$responseBody = $exception->getResponseBody();
}