PHP code example of tuupola / whereami

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

    

tuupola / whereami example snippets




use Whereami\Provider\MozillaProvider;
use Whereami\Scanner\AirportScanner;
use Whereami\Whereami;

$provider = new MozillaProvider("your-api-key-here");
$scanner = new AirportScanner;
$locator = new Whereami($provider, $scanner);

$location = $locator->whereami();

/*
Array
(
    [latitude] => 1.355989
    [longitude] => 103.992365
    [accuracy] =>  65
)
*/



use Whereami\Provider\MozillaProvider;
use Whereami\Whereami;

$provider = new MozillaProvider("your-api-key-here");
$locator = new Whereami($provider);

$location = $locator->whereami();



use Whereami\Provider\MozillaProvider;
use Whereami\Whereami;

$provider = new MozillaProvider("your-api-key-here");
$locator = new Whereami($provider);

$networks[] = [
    "name" => "#WiFi@Changi",
    "address" => "64:d8:14:72:60:0c",
    "signal" => -90,
    "channel" => 149,
];

$networks[] = [
    "name" => "#WiFi@Changi",
    "address" => "10:bd:18:5f:e9:83",
    "signal" => -70,
    "channel" => 6,
];

$location = $locator->whereis($networks);

/*
Array
(
    [latitude] => 1.3558172
    [longitude] => 103.9915859
    [accuracy] => 38
)
*/

use Whereami\Provider\CombainProvider;

$provider = new CombainProvider("your-api-key-here");

use Whereami\Provider\GoogleProvider;

$provider = new GoogleProvider("your-api-key-here");

use Whereami\Provider\BrowserlocationProvider;

$provider = new BrowserlocationProvider(null);

use Whereami\Provider\MozillaProvider;

$provider = new MozillaProvider("your-api-key-here");

use Whereami\Provider\RadiocellsProvider;

$provider = new RadiocellsProvider(null);

use Whereami\Provider\UnwiredProvider;

$provider = new UnwiredProvider("your-api-key-here");

use Whereami\Scanner\AirportScanner;

$scanner = new AirportScanner("/tmp/airport  --scan 2>&1");

use Whereami\Scanner\IwlistScanner;

$scanner = new IwlistScanner;

use Whereami\Scanner\IwlistScanner;

$scanner = new IwlistScanner("cat /tmp/iwlist.txt");



use Whereami\Adapter\CoreLocationAdapter;
use Whereami\Whereami;

$adapter = new CoreLocationAdapter;
$locator = new Whereami($adapter);

$location = $locator->whereami();

use Whereami\Adapter\CoreLocationAdapter;

$adapter = new CoreLocationAdapter;

use Whereami\Adapter\LocateMeAdapter;

$adapter = new LocateMeAdapter;

apache ALL=(ALL) NOPASSWD: /sbin/iwlist