Anymarket PHP SDK
This is a PHP SDK for Anymarket Plataform
How do I install it?
clone repository https://github.com/tiaguinho/anymarket
How do I use it?
The first thing to do is to instance a Anymarket
class. You'll need to give the token
. To obtain the token you need to ask the support.
Including the Lib
Include the lib in your project
require 'anymarket.php';
Start the development!
Create an instance of Anymarket class
Simple like this
$anymarket = new Anymarket('token');
With this instance you can start working on Anymarket's APIs.
There are some design considerations worth to mention.
-
This SDK is just a thin layer on top of an http client to handle all the requests.
-
There is JSON parsing. this SDK will include json for internal usage.
-
This SDK will include curl for internal usage.
-
To put your project in production, you need to pass the second parameter as false
$anymarket = new Anymarket('a secret', 'sandbox [true or false]');
Making GET calls
$result = $anymarket->get('/categories');
#If you wish , you can get an associative array with param $assoc = true Example:
$result = $anymarket->get('/categories', [], true);
Making POST calls
#this body will be converted into json for you
$body = ['foo' => 'bar', 'bar' => 'foo'];
$response = $anymarket->post('/categories', $body, $params);
Making PUT calls
#this body will be converted into json for you
$body = ['foo' => 'bar', 'bar' => 'foo'];
$response = $anymarket->put('/categories/123', $body);
Making DELETE calls
$response = $anymarket->delete('/categories/123')