How to read barcodes in PHP using Cloud API (low level) - ByteScout

How to read barcodes in PHP using Cloud API (low level)

  • Home
  • /
  • Articles
  • /
  • How to read barcodes in PHP using Cloud API (low level)

The source code sample below shows how to read barcodes in PHP using ByteScout Cloud API (low level).

Also, check this article to find out how to generate barcodes in PHP using Cloud API.

POST endpoint:

Code Sample:

require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: api_key
Bytescout\Client\API\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Bytescout\Client\API\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$api_instance = new Swagger\Client\Api\DefaultApi();
$types = types_example; // String | Comma-separated list of barcode types to decode. Valid types: AustralianPostCode, Aztec, CircularI2of5, Codabar, CodablockF, Code128, Code16K, Code39, Code39Extended, Code39Mod43, Code39Mod43Extended, Code93, DataMatrix, EAN13, EAN2, EAN5, EAN8, GS1, GS1DataBarExpanded, GS1DataBarExpandedStacked, GS1DataBarLimited, GS1DataBarOmnidirectional, GS1DataBarStacked, GTIN12, GTIN13, GTIN14, GTIN8, IntelligentMail, Interleaved2of5, ITF14, MaxiCode, MICR, MicroPDF, MSI, PatchCode, PDF417, Pharmacode, PostNet, PZN, QRCode, RoyalMail, RoyalMailKIX, Trioptic, UPCA, UPCE, UPU.
$pages = pages_example; // String | Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'.
$url = url_example; // String | URL of the image to decode barcodes from.

try {
    $result = $api_instance->barcodeReadFromUrlPost($types, $pages, $url);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->barcodeReadFromUrlPost: ', $e->getMessage(), PHP_EOL;