PHP code example of tabscanner / phpsdk

1. Go to this page and download the library: Download tabscanner/phpsdk 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/ */

    

tabscanner / phpsdk example snippets


use Tabscanner\Api;

$api = new Api('ApiKeyHere');

/**
 * Upload receipt to AI server to be processed
 *
 * @param $file array|string|object
 * array - single HTTP File Upload variable ($_FILES) (for array of files see upload_multiple method)
 * string - file path (used for fopen function)
 * object - a Laravel request file object (https://laravel.com/docs/5.6/requests#files)
 * 
 * @return array
 */
$file = 'receipt.jpg'; //direct grab from directory
$file2 = $_FILES['receipt']; //from upload form

$upload_response = $api->upload($file); //or $file2

//receipt token is generated from API after successful upload, else will receive error
$receipt_token = $upload_response['token'];

/**
 * Get result
 *
 * @param $token string
 * @return array - receipt data
 * - will receive status as pending or done
 * - one way to use this method is to create a loop until you get a "status done" response
 */
$result_response = $api->result($receipt_token);

upload_multiple() //accepts multi-dimensional $_FILES