PHP code example of ali-alharthi / saudiaddress

1. Go to this page and download the library: Download ali-alharthi/saudiaddress 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/ */

    

ali-alharthi / saudiaddress example snippets


'saudiaddress' => [
    'api_key' => env('SNA_API_KEY', null),
    'api_subscription' =>
    env('SNA_API_SUBSCRIPTION', 'Development'),
    'cache' => env('SNA_CACHE', true),
],

SNA_API_KEY=YOUR-API-KEY-HERE
SNA_API_SUBSCRIPTION=Development
SNA_CACHE=false

$addresses = $saudi->address()->shortAddress('short', 'E'); // return an array of address information

$verified = $saudi->address()->verifyShortAddress('ECAB2823', 'E'); // return true
$verified = $saudi->address()->verifyShortAddress('RAHA3443', 'E'); // return false


$regions = $saudi->regions()->all('E')->get();

$region = $saudi->regions()->all('E')->getId(2);

$region = $saudi->regions()->all('E')->getName('Dammam');

$cities = $saudi->cities()->all(-1, 'E')->get();

$cities = $saudi->cities()->all(3, 'E')->get();

$city = $saudi->cities()->all(-1, 'E')->getId(2);

$city = $saudi->cities()->all(-1, 'E')->getName('Dammam');

$city = $saudi->cities()->all(-1, 'E')->getGov('Eastern Province');

$districts = $saudi->cities()->all(13, 'E')->get();

$district = $saudi->cities()->all(13, 'E')->getId(2);

$district = $saudi->cities()->all(13, 'E')->getName('Dammam');

$services = $saudi->services()->categories('E')->get();

$subServices = $saudi->services()->sub(102, 'E')->get();

$service = $saudi->cities()->categories('E')->getId(102);
$subservice = $saudi->cities()->sub(102, 'E')->getId(10210);

$service = $saudi->cities()->categories('E')->getName('Commercial');
$subservice = $saudi->cities()->sub(120, 'E')->getName('Supermarket');

$address = $saudi->geo()->coordinates(24.65017630, 46.71670870, 'E')->get();

$city = $saudi->geo()->coordinates(24.65017630, 46.71670870, 'E')->getCity();

$addressOne = $saudi->geo()->coordinates(24.65017630, 46.71670870, 'E')->getAddressOne();

$addressTwo = $saudi->geo()->coordinates(24.65017630, 46.71670870, 'E')->getAddressTwo();

$street = $saudi->geo()->coordinates(24.65017630, 46.71670870, 'E')->getStreet();

$region = $saudi->geo()->coordinates(24.65017630, 46.71670870, 'E')->getRegion();

$district = $saudi->geo()->coordinates(24.65017630, 46.71670870, 'E')->getDistrict();

$buildingNumber = $saudi->geo()->coordinates(24.65017630, 46.71670870, 'E')->getBuildingNumber();

$postCode = $saudi->geo()->coordinates(24.65017630, 46.71670870, 'E')->getPostCode();

$additionalNumber = $saudi->geo()->coordinates(24.65017630, 46.71670870, 'E')->getAdditionalNumber();

$addresses = $saudi->address()->find('address string', 1, 'E')->all(); // return a list of addresses

$verified = $saudi->address()->verify(8228, 12643, 2121, 'E'); // return true
$verified = $saudi->address()->verify(9999, 99999, 9999, 'E'); // return false

 php
use AliAlharthi\SaudiAddress\SaudiAddress;

$saudi = SaudiAddress::make('API-KEY', 'Subscription', false); // Cache is disabled
$regions = $saudi->regions()->all('E')->get();