dmamontov / geohelper-api-client-php
PHP client for Geohelper API
Installs: 2 787
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.3.0
- ext-curl: *
This package is auto-updated.
Last update: 2022-01-18 01:48:47 UTC
README
PHP-client for Geohelper API.
Requirements
- PHP 5.3 and above
- PHP's cURL support
Install
-
Get composer
-
Run into your project directory:
composer require dmamontov/geohelper-api-client-php ~1.0.0
If you have not used composer
before, include autoloader into your project.
require 'path/to/vendor/autoload.php';
Usage
Get countries
$client = new \Geohelper\ApiClient( 'api_key' ); try { $response = $client->countriesList(); } catch (\Geohelper\Exception\CurlException $e) { echo "Connection error: " . $e->getMessage(); } if ($response->isSuccessful()) { $countries = isset($response['result']) ? $response['result'] : array(); foreach ($countries as $country) { echo $country['name']; } } else { echo sprintf( "Error: [HTTP-code %s] %s", $response->getStatusCode(), $response->getErrorMsg() ); }