User Guide for Gliffy PHP Client Library
Provide an overview for accessing Gliffy via PHP
Table of Contents
Gliffy provides API access via a REST API, which is essentially a set of standard URLs that respond to various HTTP requests. While this API can be used to
access Gliffy via any programming language, it is less than convienient for day-to-day usage. This document describes the PHP classes Gliffy provides
that use the REST API.
The classes you will interact with most are Gliffy and those in DataContainer. The Gliffy class provides the main functional interface, and some methods that return
data do so using the data container classes. This alleviates you from having to parse XML or deal with HTTP error codes.
Installing the Gliffy PHP Client is simply a matter of placing the files somewhere in your web server's document root, wherever PHP may execute. See your web server documentation or website administrator if you aren't sure where this is.
To configure the Gliffy PHP Client Library, copy config_example.php to config.php and modify the api key, account name, and shared secret properties. That file has extensive documentation on the configuration settings.
Validate Your Configuration
To validate your environment, the script test_configuration.php can be used, either via command-line or web. Once you have setup config.php correctly, this script will make a simple call to Gliffy using the API to make sure your configuration is correct.
Using the Gliffy PHP Client Library
You simply need to require Gliffy.php in your script. It will find the asscociated classes and your configuration file. You can then use the library by creating a new instance of Gliffy. The documentaiton for that class has examples as well as
descriptions of all available methods, but a example is included below. You can also find a simple example in the example directory that is included with this package.
// get the gliffy context object for the user email@example.com.
$gliffy = new Gliffy('firstname.lastname@example.org');
// create a diagram
$newDiagramId = $gliffy->createDiagram($newDiagramName);
// get a URL that points to an image of the new diagram
$diagramImageURL = $gliffy->getDiagramAsURL($diagramId,Gliffy::MIME_TYPE_PNG);
// get a URL for the Gliffy editor to edit this current diagram
$gliffy->getEditDiagramLink($diagramId, $_SERVER['REQUEST_URI'] ,"Back to simple demo");