Core Location
, (*1)
Proof of concept PHP implementation of Apple location services protocol. This library does not do any actual requests. It is used only for creating and parsing requests and responses., (*2)
Install
Install the library using Composer., (*3)
``` bash
$ composer require tuupola/corelocation, (*4)
## Usage
### Request
Request class returns a binary string. It is up to reader to figure out what to do with it.
```php
require __DIR__ . "/vendor/autoload.php";
use Tuupola\CoreLocation\Request;
$request = new Request(["aa:aa:aa:aa:aa:aa", "bb:bb:bb:bb:bb:bb"]);
$hex = bin2hex($request->body());
print_r(str_split($hex, 64));
/*
Array
(
[0] => 00010005656e5f55530013636f6d2e6170706c652e6c6f636174696f6e64000c
[1] => 382e342e312e313248333231000000010000002c12130a1161613a61613a6161
[2] => 3a61613a61613a616112130a1162623a62623a62623a62623a62623a62622064
)
*/
Response
Respons class can be used for unserializing the response. It is up to reader to figure out how to get a response., (*5)
require __DIR__ . "/vendor/autoload.php";
use Tuupola\CoreLocation\Response;
$data = file_get_contents("response.bin");
$response = (new Response)->fromString($data);
foreach ($response as $router) {
print_r($router);
}
/*
Array
(
[mac] => cc:cc:cc:cc:cc:cc
[latitude] => 27.98785,
[longitude] => 86.9228374
[accuracy] => 42
[channel] => 10
)
...
*/
Testing
You can run tests either manually or automatically on every code change. Automatic tests require entr to work., (*6)
``` bash
$ make test, (*7)
``` bash
$ brew install entr
$ make watch
Contributing
Please see CONTRIBUTING for details., (*8)
Security
If you discover any security related issues, please email tuupola@appelsiini.net instead of using the issue tracker., (*9)
License
The MIT License (MIT). Please see License File for more information., (*10)