djtommek / mapycz-api
Unofficial PHP 8 API wrapper for making requests to Mapy.cz
2.0.2
2023-07-08 07:18 UTC
Requires
- php: >=8.0
- ext-curl: *
- ext-simplexml: *
- guzzlehttp/guzzle: ^7.0
- psr/http-client: ^1.0
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9
README
Simple API wrapper for making requests to Mapy.cz created by the Czech company Seznam.cz. No API credentials are required.
Installation
composer require djtommek/mapycz-api
Usage example
<?php $api = new \DJTommek\MapyCzApi\MapyCzApi(); $place = $api->loadPoiDetails('base', 2107710); printf('lat: %F, lon: %F', $place->getLat(), $place->getLon()); // lat: 50.132131, lon: 16.313767
See tests or examples for more.
Testing
composer test
Note: The tests are making actual requests to the Mapy.cz website.
Detailed info
Mapy.cz frontend is communicating with backend via FastRPC requests and responses, which are XML-RPC binary encoded by their own custom encoder written in Javascript. See github.com/seznam/fastrpc or seznam.github.io/frpc.
Instead of creating PHP implementation of this FastRPC encoder/decoder, this wrapper is using HTTP headers:
Content-Type: text/xml
to send requests using classic formatted in XML-RPC.Accept: application/json
to receive responses in JSON.
Disclaimer
- Mapy.cz can change any time without any warning.
- Personally, I would recommend not making extensive or malicious requests to prevent being banned. More info can be found on api.mapy.cz.