Sample Applications

From API Documentation

Revision as of 12:35, 5 October 2012 by WikiSysop (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Below are sample applications built using the API, coded using PHP. These samples demonstrate a variety of common use cases. While we do not cover every possible use of the API here, these samples are meant to be indicative of all API calls.

All examples use the cURL library for handling the HTTP request. There are other methods available in PHP (and other languages, of course), and any method that allows you to send and receive the properly formatted requests and responses is perfectly acceptable.

Sample 1: mailing list signup form

This application allows a site visitor to add himself or herself to an agent's consists

// Set some universal configuration variables. These will be
// the same for all your API requests for a particular account.
$strUsername = 'YOUR_API_USERNAME';
$strPassword = 'YOUR_API_PASSWORD';
$strBaseURI = '';
// Set some configuration variables specific to the task at hand.
// In this example, we'll be reading data from the agents collection
// resource. We'll retrieve the data in CSV format.
$strResourcePath = 'agents';
$strRequestFormat = 'text/plain';
$strResponseFormat = 'text/csv';
// Open a cURL resource
$ch = curl_init();
Personal tools