2017 © Pedro Peláez
 

library classy-php-sdk

Php HTTP client library for Classy API

image

classy-org/classy-php-sdk

Php HTTP client library for Classy API

  • Wednesday, August 3, 2016
  • by PGBI
  • Repository
  • 25 Watchers
  • 4 Stars
  • 1,701 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 20 % Grown

The README.md

Classy PHP SDK Build Status codecov.io

This repository contains a php HTTP client library to let your php App interact with Classy's API., (*1)

Installation

The Classy PHP SDK can be installed with Composer:, (*2)

composer require classy-org/classy-php-sdk

Be sure you included composer autoloader in your app:, (*3)

require_once '/path/to/your/project/vendor/autoload.php';

Usage

Basic example

$client = new \Classy\Client([
    'client_id'     => 'your_client_id',
    'client_secret' => 'your_client_secret',
    'version'       => '2.0' // version of the API to be used
]);

$session = $client->newAppSession();

// Get information regarding the campaign #1234
$campaign = $client->get('/campaigns/1234', $session);

// Access the campaign goal: $campaign->goal

// Unpublish the campaign
$client->post('/campaign/1234/deactivate', $session);

Sessions handling

Sessions have an expiration date. It is possible to refresh a session:, (*4)

if ($session->expired()) {
    $client->refresh($session)
}

// $session->expired() is now false.

Sessions are serializable, they can be saved an reused to reduce the amount of API calls:, (*5)

$client = new \Classy\Client([
    'client_id'     => 'your_client_id',
    'client_secret' => 'your_client_secret',
    'version'       => '2.0' // version of the API to be used
]);

// Retrieve the session from a file
$session = unserialize(file_get_contents("path/to/a/cache/file"));

// ... work with the API...

// Save the session for later
file_put_contents("path/to/a/cache/file", serialize($session));

Errors handling

This client can throw two types of Exceptions:, (*6)

  • Classy\Exceptions\SDKException when the SDK is misused
  • Classy\Exceptions\APIResponseException when the API is not returning an OK response
try {
    $response = $client->get('/endpoint', $session);
} catch (\Classy\Exceptions\APIResponseException $e) {
    // Get the HTTP response code
    $code = $e->getCode();
    // Get the response content
    $content = $e->getResponseData();
    // Get the response headers
    $headers = $e->getResponseHeaders();
}

The Versions

03/08 2016

dev-master

9999999-dev

Php HTTP client library for Classy API

  Sources   Download

The Requires

 

The Development Requires

03/08 2016

1.1.0

1.1.0.0

Php HTTP client library for Classy API

  Sources   Download

The Requires

 

The Development Requires

03/08 2016

1.0.6

1.0.6.0

Php HTTP client library for Classy API

  Sources   Download

The Requires

 

The Development Requires

19/07 2016

1.0.5

1.0.5.0

Php HTTP client library for Classy API

  Sources   Download

The Requires

 

The Development Requires

19/07 2016

1.0.4

1.0.4.0

Php HTTP client library for Classy API

  Sources   Download

The Requires

 

The Development Requires

18/07 2016

1.0.3

1.0.3.0

Php HTTP client library for Classy API

  Sources   Download

The Requires

 

The Development Requires

15/07 2016

1.0.2

1.0.2.0

Php HTTP client library for Classy API

  Sources   Download

The Requires

 

The Development Requires

30/05 2016

1.0.1

1.0.1.0

Php HTTP client library for Classy API

  Sources   Download

The Requires

 

The Development Requires

19/04 2016

1.0.0

1.0.0.0

Php HTTP client library for Classy API

  Sources   Download

The Requires

 

The Development Requires