PHP code example of osenco / glovo
1. Go to this page and download the library: Download osenco/glovo 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/ */
osenco / glovo example snippets
$apiKey = '125238463972712';
$apiSecret = '081f8c9680d457a088b4413a62ddf84c';
sen\Glovo\Service;
use Osen\Glovo\Exception;
use Osen\Glovo\Models\Order;
use Osen\Glovo\Models\Address;
// get credentials on https://business.glovoapp.com/dashboard/profile or https://business.testglovo.com/dashboard/profile
$api = new Service( $apiKey, $apiSecret);
$api->sandbox_mode( true );
$source = new Address( Address::TYPE_PICKUP, -34.919861, -57.919027, "Diag. 73 1234", "1st floor" );
$destination = new Address( Address::TYPE_DELIVERY, -34.922945, -57.990177, "Diag. 73 75", "3A");
$order = new Order();
$order->setDescription( "1 big hammer" );
$order->setAddresses( [$source, $destination] );
//$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();
}
bash
$ chmod +x ./update_certs.php
$ ./update_certs.php