GithubHelp home page GithubHelp logo

hasoffers-api-wrapper's Introduction

HasOffers API Wrapper

A simple PHP wrapper for the HasOffers API

Setup

Setting up the wrapper is fairly straightforward. Simply open up HasOffersApiImpl.php and place your API key, Network ID, and API domain in the appropriate locations (denoted by placeholders) and you're good to go.

Usage

To use the wrapper, you'll need to include the SimpleHasOffersApi.php file. Just instantiate a new instance:

require_once('php/lib/HasOffers/SimpleHasOffersApi.php');

$api = new SimpleHasOffersApi();

From there, you'll want to prepare your query by running:

$api->prepare('Offer', 'findById');

The prepare function requires 2 parameters; the target (generally one of the API objects) and the method of that object to call (information for which can be found on the HasOffers API Wiki).

After we prepare our query, we need to add some parameters (for most method calls, at least):

$api->addParameter('id', 'YOUR OFFER ID');

The addParameter function accepts 2 different styles of arguments:

  • A key as parameter 1, and a value as parameter 2
  • A key as parameter 1, and a variable number of parameters that will become the array value of parameter 1

For example, in the case of the second argument format:

$api->addParameter('id', 10, 11, 12, 13)

would be the same as running:

$api->addParameter('id', array(10, 11, 12, 13))

After all of your paramters have been added, all that's left to do is execute the query:

$result = $api->execute();

This will return the JSON-decoded value that HasOffers replies with. The format of this object will vary depending on what object you targeted and method you called (again, refer to the HasOffers API documentation for more details).

API objects can also be recylced. If you need to make multiple calls during a single script instance, just follow all the above steps again. Make sure that the prepare function is ran first! Interally, this will clear out all stored parameters before setting the target and method.

hasoffers-api-wrapper's People

Contributors

larttyler 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.