PHP code example of robo-meister / flow-scribe-api
1. Go to this page and download the library: Download robo-meister/flow-scribe-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
robo-meister / flow-scribe-api example snippets
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;
}
$result = $client->processDocument(__DIR__ . '/upload.pdf', [
'document_type' => 'auto',
'mode' => 'fuse',
'source_document_id' => 'doc_123',
'workspace_id' => 'workspace_123',
'org_id' => 'org_123',
'user_id' => 'user_123',
'context_type' => 'UniversalDropzone',
'context_id' => 'dropzone_upload_123',
// Connector base URL; FlowScribe appends /api/integration/document/ocr-completed.
'rc_callback_url' => 'https://connector.example.com',
'document_name' => 'Vendor invoice.pdf',
'return_review_payload' => true,
'
use Robo\FlowScribeOcr\FlowScribeOcrClient;
$client = new FlowScribeOcrClient(
baseUrl: 'https://ocr.robo-meister.com',
accessToken: getenv('FLOWSCRIBE_ACCESS_TOKEN') ?: null
);
$queued = $client->ingestUniversalDropzoneDocument(__DIR__ . '/dropzone.pdf', [
'source_document_id' => 'doc_123',
'workspace_id' => 'workspace_123',
'org_id' => 'org_123',
'context_type' => 'UniversalDropzone',
'context_id' => 'upload_123',
// Connector base URL; FlowScribe appends /api/integration/document/ocr-completed.
'rc_callback_url' => 'https://connector.example.com',
'idempotency_key' => 'upload_123',
'correlation_id' => 'corr_123',
]);
$jobId = $queued['data']['job']['id'];
$status = $client->flowScribeStatus($jobId);
$queued = $client->ingestRcDocument(__DIR__ . '/contract.pdf', [
'source_document_id' => 'doc_456',
'workspace_id' => 'workspace_123',
'org_id' => 'org_123',
'document_name' => 'Customer contract.pdf',
]);
$result = $client->processDocumentForReview(__DIR__ . '/invoice.pdf', [
'workspace_id' => 'workspace_123',
'org_id' => 'org_123',
]);
$reviewPayload = $result['review_payload'] ?? null;
$preview = $result['preview'] ?? null;
$storage = $result['storage'] ?? null;
$diagnostics = $client->diagnostics(
organisationId: 'org_123',
workspaceId: 'workspace_123'
);
if (($diagnostics['diagnostics_available'] ?? true) === false) {
$health = $diagnostics['health'];
$metadata = $diagnostics['metadata'];
}
$result = $client->processDocument(__DIR__ . '/invoice.pdf', [
'config_path' => __DIR__ . '/custom-dictionary.json',
]);
$result = $client->processDocument(__DIR__ . '/invoice.pdf', [
'config' => [
'fields' => [
'invoiceNumber' => ['keywords' => ['Invoice #']],
],
],
]);
use Robo\FlowScribeOcr\FlowScribeOcrException;
try {
$result = $client->processDocument(__DIR__ . '/invoice.pdf');
} catch (FlowScribeOcrException $exception) {
$statusCode = $exception->getStatusCode();
$responseBody = $exception->getResponseBody();
$rawBody = $exception->getRawResponseBody();
$correlationId = $exception->getCorrelationId();
$errorCode = $exception->getErrorCode();
}