There is no license information available for the latest version (1.0.1) of this package.

PHP client for REST API

1.0.1 2015-07-27 07:50 UTC

This package is not auto-updated.

Last update: 2024-06-08 13:59:04 UTC



This library provides an API to create and update infographics on


The recommended way to install Infogram-PHP is via Composer. Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.

# Install Composer
curl -sS | php

Add the following dependency to the require section of your project's composer.json:

"require": {
  "infogram/infogram": "1.0.*"

Execute command line composer update in your project's root

API Keys

You're going to need API keys, the public key and the secret (or private) key, to be able to access API service. To find your keys, log in to, find the account settings on the left panel and look for the API credentials. Keep your secret key secret, don't send it to anyone and do not pass it to any service directly.

The public key is used to indentify the API account the code is accessing with and the secret key is used to sign every request, i.e., add additional parameter to the request query string or body.


Making a Request

For making a request, two Infogram-PHP classes are essential: Infogram\RequestSigningSession and Infogram\InfogramRequest. The former is responsible for HTTP request signing using the provided API secret key and the latter performs HTTP requests to the API service.

TODO: add reference to HTTP API documentation

use Infogram\InfogramRequest;
use Infogram\RequestSigningSession;
$consumerKey = 'Your public key';
$consumerSecret = 'Your secret key';
$session = new RequestSigningSession($consumerKey, $consumerSecret);
$request = new InfogramRequest($session, 'GET', 'themes');
$response = $request->execute();

Using a Response

Method Infogram\InfogramRequest::execute returns an instance of class Infogram\InfogramResponse or null if API server cannot be accessed.

Infogram\InfogramResponse contains (1) HTTP status code from last API request, (2) HTTP response body, (3) HTTP response headers

$content = array(
    'type' => 'h1',
    'text' => 'hello'
$session = new RequestSigningSession($consumerKey, $consumerSecret);
$request = new InfogramRequest($session, 'POST', 'infographics', array('content' => $content));
$response = $request->execute();
if (! $response) {
   die("Could not contact API server\n");
if (! $response->isOK()) {
   die('Error executing API request: ' . $response->getBody() . "\n");
echo 'Created new infographic with ID: ' . $response->getHeader('X-Infogram-Id') . "\n";

On successful request ($response->isOK() == true), response's method getBody returns either a string or array (converted from a JSON string) if applicable. On error (! $response->isOK()), getBody returns string which contains the error message if there is any.