Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

dynata/php-sample-api-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

php-sample-api-sdk

Requirements in composer.json file

{
  "require": {
      "peanut-labs/php-sample-api-sdk": "dev-master"
  },
  "repositories": [
      {
          "url": "git@github.com:peanut-labs/php-sample-api-sdk.git",
          "type": "git"
      }
  ]
}

bootstraping

In order to use the SDK you need to make sure its classes are autoloaded, composer would normally take care of this, if for some reason this doesn't happen just make sure the SDK's autoload.php file is required at some point.

Then you need to instantiate a Client object

SDK has its own namespace and the constructor for a Client object has three parameters, $client_id, $security_key and $host.

Example:

use PeanutLabs\SampleApiSDK\Client;

$client = new Client($client_id, $security_key, $host);

$client_id is a unique identifier provided to you by Peanut Labs.

$security_key is a secret key provided to you by Peanut Labs.

$host is the base URI of the Sample API, like 'http://sample.peanutlabs.com/sample'.

Usage

There is only one method sendRequest, which will return a Response object.

Method sendRequest will expect three parammeters, $method, $path, $params.

Example calls using the bootstrapped client object globally:

global $client;

$response = $client->sendRequest($method, $path, $params);

$method is HTTP method, like GET and POST.

$path is the resource path, like '/projects/test001'.

$params is all the request params as a php array.

Parsing Response

There are two methods getResponseBody and getHttpStatusCode.

Example:

$response_body = $response->getResponseBody();
$http_status_code = $response->getHttpStatusCode();

About

This is the php sdk to communicate with the new restful sample api built for pl core.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages