PHP code example of rgsystemes / apimapper
1. Go to this page and download the library: Download rgsystemes/apimapper 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/ */
rgsystemes / apimapper example snippets
$browser = new Buzz\Browser();
$mapper = new ApiMapper\ApiMapper($browser, 'https://api.baseurl.com/api');
$mapper->addEventListener(new AuthenticationListener($sessionManager));
$mapper->addQueryParameter('apiKey', new ApiKeyProvider('someApiKey'));
$mapper->addRouteParameter('{token}', new AuthenticationProvider($sessionManager));
// https://api.baseurl.com/api/auth?apiKey=someApiKey&userName=$userName&password=$password
$response = $mapper->get('auth', array(
"userName" => $userName,
"password" => $password
));
// There is no need here to provide the token since it has been
// wrapped when calling auth.
// https://api.baseurl.com/api/1234/some/obscure/12/route
$response = $mapper->get('{token}/some/obscure/{someId}/route', array(
"{someId}" => 12
));