PHPGraphlib Remote API

The PHPGraphLib Remote API allows you to create PHPGraphLib graphs without ever having to download the PHPGraphLib library. Instead, you format your request and send it to the API graph generator URI. The API graph generator then creates an image of your requested graph on the PHPGraphLib servers and sends you back the remote location of the created image. Simply include that location in a an html <img> tag to display your graph.

Why Use the Remote API?

Scalability - You won't have to worry about having multiple copies of PHPGraphLib on different instances.

Stability - You'll always be using the latest version of PHPGraphLib. No need to upgrade!

Usage Policy

The PHPGraphLib API has the same usage policy as PHPGraphLib - it is free for personal use and requires a small fee for commercial use. For more information, see the Usage Policy.

Getting Started

Constructing Your Request

PHPGraphlib Remote API calls can return data in two different formats, XML and URL (plain text). The XML format allows more useful information to be sent back to you, while the URL plain text format only returns the fully quallifed location of the graph image.

Graph Parameters

To build your graph parameters, construct an object of type stdclass. Just like the library, there are 3 required variables: width, height and data. Syntax is different, but similar, to the regular PHPGraphLib library.

To customize the your request to the API Graph Generator, you assign the name of the PHPGraphLib library function to the object, and pass the normal parameters of the function as the value. If there is more than one parameter passed to the function, you need to assign those values as an array. Also, if the parameter is boolean, you need to assign it with single or double quotes.

Note: not all PHPGraphlib functions are allowed with the API, though *most* are. If you're in doubt, consult the
Function Reference
for API availability.

Serializing Your Request with JSON

JSON is the preferred method of sending graph parameters to the API graph generator because it is language independent and very lightweight. Using JSON with PHP depends on your version of PHP. If you are using a different programming language than PHP to construct your requests, you'll need to use your language's JSON implementation.

PHP Version

JSON Usage

PHP 5.2 +

Starting with PHP 5.2.0, the JSON package was bundled with PHP.
You can use the json_encode() and json_decode() functions without
any further configuration.