Giter Club home page Giter Club logo

exads-api-client-php's Introduction

Exads API PHP Client

A simple Object Oriented wrapper for Exads API, written with PHP5.

See Exads API's documentation.

Features

  • Follows PSR-0 conventions and coding standard: autoload friendly
  • API entry points implementation state :
  • Campaign
  • Collection
  • Login
  • Payment
  • Site
  • Statistics
  • User
  • Zones

Requirements

  • PHP >= 5.4
  • The PHP cURL extension
  • The PHP JSON extension
  • PHPUnit >= 4.0 (optional) to run the test suite

Install

Composer

Composer users can simply run:

$ php composer.phar require exads/exads-api-client-php:~1.0

at the root of their projects. To utilize the library, include Composer's vendor/autoload.php in the scripts that will use the Exads classes.

For example,

<?php

// This file is generated by Composer
require_once 'vendor/autoload.php';
$client = new Exads\Client('https://api.exoclick.com/v1/');
// ...

Standalone (not recommended)

The library ships with a basic autoload.php file which allows you to use it without composer. See the latest version available : https://github.com/EXADS/exads-api-client-php/releases

$ mkdir vendor
$ wget -q https://github.com/EXADS/exads-api-client-php/archive/v1.2.0.tar.gz
$ tar -xf v1.2.0.tar.gz -C vendor/
$ rm v1.2.0.tar.gz

Then your bootstrap script should look like :

<?php

// This file ships with the library
require 'vendor/exads-api-client-php-1.0.0/lib/autoload.php';
$client = new Exads\Client('https://api.exoclick.com/v1/');

Basic usage of exads-api-client-php client

<?php

require_once 'vendor/autoload.php';

try {
    $client = new Exads\Client('https://api.exoclick.com/v1/');

    // There are two authentication methods:
    // a. with username and password
    $sessionToken = $client->login->getToken('username', 'password');
    // b. with APItoken
    // $sessionToken = $client->login->getToken('APItoken');

    $client->setApiToken($sessionToken);
    // ...
    $campaigns = $client->campaigns->all();
    // ...
} catch (\Exception $e) {
    die($e->getMessage());
}

See test/Exads/Tests/UrlsTest.php for a full list of available methods.

Passing parameters to end points

As describe in the API documentation, most of the GET entry points accept parameters for filtering the result of the call. In particular, for long collections, you should use offset for paginating the results the API returns (you cannot get more than 50 elements out of 1 call, that's when offset comes in play). See the following examples :

<?php
...

// Getting the total number of carriers
$client->collections->carriers(array('count' => true));

// Getting the carriers 50..100
$client->collections->carriers(array('offset' => 50));

Please refer to the documentation for the full list of parameters allowed for each entry point.

exads-api-client-php's People

Contributors

b202020 avatar cradonn avatar drsdre avatar kbsali avatar wardloockx avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.