droath / recurly_client
Recurly REST API services.
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ~5.2
- symfony/serializer: ~2.6
Requires (Dev)
- phpunit/phpunit: ~4.5
This package is not auto-updated.
Last update: 2024-11-09 17:24:56 UTC
README
The Recurly Client library allows you to simply interact with the exposed RESTful API Services provided by Recurly.com.
We're using the PHP Guzzle library to construct the HTTP requests for the available Recurly web services. This will give us the opportunity to leverage Guzzle and its pluggable HTTP adapters. Hopefully it will make for a more feature rich experience when handling the Recurly web services.
Requirements
The PHP library depends on PHP 5.4 or higher.
NOTE: Currently we don't support PHP:hhvm, due to HHVM not fully supporting the SimpleXMLIterator class.
Installation
Composer
If you're using Composer, you can simply add a dependency droath/recurly_client
to your project's composer.json file. Here's a snippet of the composer.json.
{
"require": {
"droath/recurly_client": "*"
}
}
Usage
Configuration
Set the Recurly API key and subdomain, which are defined within your Recurly Account.
<?php $config = new \RecurlyClient\Config( 'abcdef01234567890abcdef01234567890', 'your-subdomain' ); $client = new \RecurlyClient\Client($config);
Service Manager
Request types
Display the available request types for a particular Recurly service.
<?php ... $service = new \RecurlyClient\Service\Account(); $manager = new \RecurlyClient\ServiceManager($client, $service); $request_types = $manager->getRequestTypes(); print $request_types;
Invoke
Display the Recurly response object based on the invoked request type action.
<?php ... $service = new \RecurlyClient\Service\Account(); $manager = new \RecurlyClient\ServiceManager($client, $service); try { $response = $manager->invoke('list')->execute(); } catch (Exception $e) { // Handle errors here } print $response;
Response
Extract
Simply extract the data that was retrieved from the Recurly web service. The data can be extracted from the response in the following formats: Array, JSON, or XML.
<?php ... try { $response = $manager->invoke('list')->execute(); } catch (Exception $e) { // Handle errors here } // Available formats are: array, json, xml. $data = $response->getData()->extract('array');