Download the PHP package traackr/traackr-api-php without Composer

On this page you can find all versions of the php package traackr/traackr-api-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package traackr-api-php

Traackr API - PHP Client

Build Status

Introduction

This is a PHP implementation of the Traackr API. Documentation for this PHP client is available here: http://traackr.github.io/traackr-api-docs.
For documentation for the Traackr API itself, see: http://api.docs.traackr.com.

Installation

You can clone this GitHub repository to get the latest version of the code.

This library is also available via Composer if that's what you use to manage your dependencies. To do this, simply add this to your composer.json file:

"minimum-stability": "dev",
"require": {
    "traackr/traackr-api-php": "dev-master"
}

Usage

You will need an API key to make use this library. Contact [email protected] to get your key.

Include the library

You include this library with:

require_once('lib/TraackrApi.php');

If you are using Composer the autoload functionality should automatically load the appropriate PHP files (i.e. require 'vendor/autoload.php' will load the library files).

Set your API key

To set your API key use:

TraackrApi::setApiKey(<your-api-key>);

Some calls require a Customer Key (see documentation). You do not need to pass this key to these calls. You can set (once and for all) your Customer Key with:

TraackrApi::setCustomerKey(<your-customer-key);

The client library will take care of including your customer key when needed.

Note that you can also specify your API key and customer key via environment variables. See the unit tests section.

API calls

All API calls map to static functions with parameters matching the API call parameters (see documentation). For instance to call /influencers/show you can use:

Influencers::show(<influencer-uid>);

Logging

You can tie the client's internal logging into your own application's logging by creating an implementation of the ApiLoggingInterface. Here's an example from CakePHP:

class ApiLogger implements Traackr\ApiLoggerInterface
{
   private $parentObj;

   public function __construct($obj) {
      $this->parentObj = $obj;
   }

   public function debug($string) {
      $this->parentObj->log($string, LOG_DEBUG);
   }

   public function error($string) {
      $this->parentObj->log($string, LOG_WARNING);
   }
}

Then, create an instance of your implementation before any API calls are made (e.g. in a constructor):

Traackr\TraackrApi::setLogger(
   new ApiLogger($this)
);

Unit Tests

Setup

To run unit tests, you will need to install dependencies required by this project. First, install Composer locally:

$ curl -sS https://getcomposer.org/installer | php

Then install dependencies:

$ php composer.phar install

Running the tests

The unit tests come with a public API key that you can use to run the unit tests. However the API key provided in the unit tests is only allowed to access read-only end points (i.e. API calls that do not add, modify or delete any data).
To run these read-only tests you can execute:

./bin/phpunit --group read-only test

If you try to run the entire test suite with this public API key you will get errors when trying to access functions that change data.

Running the entire test suite

To run the entire test suite you will need an API key that has full access to the API. You can request one by emailing [email protected].

Before you run unit tests, you need to specify an API key and a Customer key. These 2 values can be specified via ENV variables (so they don't have to be hardcoded in the unit tests).

# export TRAACKR_API_KEY=<your-api-key>
# export TRAACKR_CUSTOMER_KEY=<your-customer-key>

Run the entire test suite:

./bin/phpunit test

All versions of traackr-api-php with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
ext-curl Version *
ext-json Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package traackr/traackr-api-php contains the following files

Loading the files please wait ....