PHP code example of smart-dato / dhl-unified-sdk

1. Go to this page and download the library: Download smart-dato/dhl-unified-sdk 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/ */

    

smart-dato / dhl-unified-sdk example snippets


return [
    'api_key' => env('DHL_UNIFIED_API_KEY'),
    'base_url' => env('DHL_UNIFIED_BASE_URL', 'https://api.dhl.com'),
    'delay_ms' => (int) env('DHL_UNIFIED_DELAY_MS', 0),
];

use SmartDato\DhlUnified\DhlUnified;
use SmartDato\DhlUnified\Enums\LocationType;

$dhl = app(DhlUnified::class); // from config
$dhl = DhlUnified::make(['api_key' => '...', 'delay_ms' => 1000]); // explicit

$lockers = $dhl->locations()->findByGeo(
    latitude: 50.72,
    longitude: 7.11,
    countryCode: 'DE',
    radiusInMeters: 5000,
    limit: 50,
    locationType: LocationType::Locker,
);

$lockers[0]->id();                   // "8003-4103145", id of the unified record
$lockers[0]->location->keyword;      // "Packstation"
$lockers[0]->location->keywordId;    // "145", used when addressing a shipment
$lockers[0]->place->address->postalCode;

$dhl->locations()->findByAddress(countryCode: 'DE', postalCode: '53113');
$dhl->locations()->get('8003-4103145');
bash
php artisan vendor:publish --tag="dhl-unified-sdk-config"