Glovo Business API Implementation.
PHP 7.2 and later.
You can install the bindings via Composer. Run the following command:
$ composer require konectdigital/glovo-api
The bindings require the following extensions in order to work properly:
If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.
Create an account in Glovo (it can be created from the App). This api needs a credit card associated to your account. You can add one from your app and it will be used automatically for any order. In order to get your API credentials you should login in the desired environment and go to Credentials section on your profile.
Example ApiKey & ApiSecret:
$apiKey = '125238463972712';
$apiSecret = '081f8c9680d457a088b4413a62ddf84c';
Simple usage looks like:
<?php
include 'vendor/autoload.php';
use GlovoApi;
use Konectdigital\GlovoApi\Model\Order;
use Konectdigital\GlovoApi\Model\Address;
// get credentials on https://business.glovoapp.com/dashboard/profile or https://business.testglovo.com/dashboard/profile
$api = new GlovoApi( '125238463972712', '081f8c9680d457a088b4413a62ddf84c' );
$api->sandbox_mode( true );
$sourceDir = new Address( Address::TYPE_PICKUP, -34.919861, -57.919027, "Diag. 73 1234", "1st floor" );
$destDir = new Address( Address::TYPE_DELIVERY, -34.922945, -57.990177, "Diag. 73 75", "3A");
$order = new Order();
$order->setDescription( "1 big hammer" );
$order->setAddresses( [$sourceDir, $destDir] );
//$order->setScheduleTime( ( new \DateTime( '+1 hour' ) )->setTime( 19, 0 ) );
try {
$orderEstimate = $api->estimateOrderPrice( $order );
echo "Estimate: {$orderEstimate['total']['amount']}{$orderEstimate['total']['currency']} \n";
} catch(Exception $e){
echo $e->getMessage();
}
try {
$orderInfo = $api->createOrder( $order );
echo "Order created, ID: {$orderInfo['id']}, state: {$orderInfo['state']} \n";
} catch(Exception $e){
echo $e->getMessage();
}
See full example in example.php
In order to update the CA Root certificates you can run:
$ chmod +x ./update_certs.php
$ ./update_certs.php
You can read [the Glovo B2B API docs][https://api-docs.glovoapp.com/b2b/index.html#introduction].