PHP code example of valentinmari / glovo-api-php

1. Go to this page and download the library: Download valentinmari/glovo-api-php 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/ */

    

valentinmari / glovo-api-php example snippets




$apiKey = '125238463972712';
$apiSecret = '081f8c9680d457a088b4413a62ddf84c';



lovo\Api;
use Glovo\Model\Order;
use Glovo\Model\Address;


// get credentials on https://business.glovoapp.com/dashboard/profile or https://business.testglovo.com/dashboard/profile
$api = new Api( '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 ) );

$orderEstimate = $api->estimateOrderPrice( $order );

echo "Estimate: {$orderEstimate['total']['amount']}{$orderEstimate['total']['currency']} \n";

$orderInfo = $api->createOrder( $order );

echo "Order created, ID: {$orderInfo['id']}, state: {$orderInfo['state']} \n";
bash
$ composer 

$ chmod +x ./update_certs.php
$ ./update_certs.php