PHP code example of dhl / sdk-api-location-finder

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

    

dhl / sdk-api-location-finder example snippets


$sandboxMode = false;
$serviceFactory = new \Dhl\Sdk\LocationFinder\Service\ServiceFactory();
$service = $serviceFactory->createLocationFinderService(
    'appId',
    'appToken',
    new \Psr\Log\NullLogger(),
    $sandboxMode
);

try {
    /** @var \Dhl\Sdk\LocationFinder\Api\Data\LocationInterface $locations  */
    $locations = $service->getPickUpLocations(
        'DE',
        '04129',
        'Leipzig',
        'Nonnenstraße',
        '11d'
    );
} catch (\Dhl\Sdk\LocationFinder\Exception\ServiceException $e) {
    // handle errors
}

foreach ($locations as $location) {
    echo $location->getName();
    echo $location->getType();
    echo $location->getLatitude();
    echo $location->getLongitude();
    // ...
}