This open source project is a an example of how to scan barcodes using a smartphone and present data from your system using PHP.
How it works:
- A user scans a barcode using their smartphone
- Orca Scan sends a HTTP GET request to your endpoint with
?barcode=value
- Your system queries a database or internal API for a
barcode
match - Your system returns the data in JSON format with keys matching column names
- The Orca Scan mobile app presents that data to the user
If the mobile user has update permission and saves the data, it will saved to your Orca sheet.
First ensure you have PHP installed:
# should return 7.1 or higher
php -v
Then execute the following:
# download this example code
git clone https://github.com/orca-scan/orca-lookup-php.git
# go into the new directory
cd orca-lookup-php
# start the server
php -S localhost:5000
Visit http://localhost:5000?barcode=4S3BMHB68B3286050 to see the following:
{
"VIN": "4S3BMHB68B3286050",
"Make": "SUBARU",
"Model": "Legacy",
"Manufacturer Name": "FUJI HEAVY INDUSTRIES U.S.A",
"Vehicle Type": "PASSENGER CAR",
"Year": 1992
}
This is a very simple example using 1 index.php script:
<?php
// set HTTP content type
header("Content-Type: application/json");
// get the incoming barcode sent from Orca Scan (scanned by a user)
$barcode = $_GET['barcode'];
// TODO: query a database or API to retrieve some data based on barcode value
// build up data to return as an object (property names must match Orca column names inc spaces)
$data = [
'VIN' => $barcode,
'Make' => "SUBARU",
'Model' => "Legacy",
'Manufacturer Name' => "FUJI HEAVY INDUSTRIES U.S.A",
'Vehicle Type' => "PASSENGER CAR",
'Year' => 1992
];
// return data as JSON object
echo json_encode($data);
?>
If you run into any issues not listed here, please open a ticket.
For change-log, check releases.
Licensed under MIT License © Orca Scan, the Barcode Scanner app for iOS and Android.