A PHP class method to access the Bricklink API using cURL library.
##Usage
$BricklinkApi = new /PHPBricklinkApi/BricklinkAPI([
'tokenValue' => {TOKEN},
'tokenSecrect' => {TOKEN_SECRET},
'consumerKey' => {CONSUMER_KEY},
'consumerSecret' => {CONSUMER_SECRET}
]);
$response = $BricklinkApi->request({HTTP_METHOD}, {API_PATH}, {PARAMS})
->execute();
- PHP 5.5+
- cURL library extension
new /PHPBricklinkApi/BricklinkApi($params);
Returns
Returns a new instance of the BricklinkApi class.
Constructor Parameters $params
Passed as an associative array of keys and values. Accepted key values are:
- $endpoint: Allows you to overide the default Bricklink Api endpoint.
- $consumerKey: The consumer secret for your Bricklink API account. Value found at Bricklink API Registration Page
- $consumerSecret: The consumer secret for your Bricklink API account. Value found at Bricklink API Registration Page
- $tokenValue: The token key from your Bricklink API Access Tokens. Value found at Bricklink API Registration Page
- $tokenSecret: The token secret from your Bricklink API Access Tokens. Value found at Bricklink API Registration Page
- $isDevelopment: Allows unsecure connections for easier localhost development.
$BricklinkApi->request($httpMethod, $apiPath, $params);
A shorthand can also be used to create a request and execute it.
$BricklinkApi->get($apiPath,$params=[]);
is equivalent to
$BricklinkApi->request("GET", $apiPath, $params);
And so on for the other common REST methods.
$BricklinkApi->post($apiPath,$params=[]);
$BricklinkApi->put($apiPath,$params=[]);
$BricklinkApi->delete($apiPath,$params=[]);
Returns
Returns your BricklinkApi instance to enable chaining.
Parameters
- $httpMethod: Use the common REST methods. i.e. - GET, POST, PUT, DELETE
- $apiPath: The relative path of the api. Should include a leading
/. - $params: An associative array, according to the [Bricklink API docs] (http://apidev.bricklink.com/redmine/projects/bricklink-api/wiki).
'box' => true,
'instructions' => true];```
### Execute request
$BricklinkApi->request($httpMethod, $apiPath, $params)->execute();
__Returns__
Returns and instance of BricklinkApiResponse