Sample Applications

From API Documentation

(Difference between revisions)
Jump to: navigation, search
(Created page with '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 h…')
Line 4: Line 4:
== Sample 1: mailing list signup form ==
== Sample 1: mailing list signup form ==
-
This application allows a site visitor to add himself or herself to an agent's consists  
+
This application allows a site visitor to add himself or herself to a an agent's contact list, while also adding the new contact to a predefined distribution list. The application consists of two files: an HTML file containing a simple signup form, and a PHP file which processes form submissions and makes the necessary API calls.
 +
<source lang="html">
 +
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 +
  <head>
 +
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 +
    <title>Rezora API Sample: Add a Contact</title>
 +
  </head>
 +
  <body>
 +
    <h1>Add a Contact</h1>
 +
    <form action="form_processor.php" method="post" name="addcontactform" id="addcontactform">
 +
      <div>
 +
        <label for="name">Name:</label>
 +
        <input type="text" name="name" id="name" value="" />
 +
      </div>
 +
      <div>
 +
        <label for="email">Email address:</label>
 +
        <input type="text" name="email" id="email" value="" />
 +
      </div>
 +
      <div>
 +
        <input type="submit" value="Submit" />
 +
      </div>
 +
    </form>
 +
  </body>
 +
</html>
 +
</source>
<source lang="php">
<source lang="php">
-
<?php
+
</source>
-
// 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 = 'http://api.rezora.com/v1/';
+
-
 
+
-
// 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();
+

Revision as of 12:40, 5 October 2012

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 a an agent's contact list, while also adding the new contact to a predefined distribution list. The application consists of two files: an HTML file containing a simple signup form, and a PHP file which processes form submissions and makes the necessary API calls.


GeSHi Error: GeSHi could not find the language html (using path /var/api/htdocs/api/documentation/extensions/SyntaxHighlight_GeSHi/geshi/geshi/) (code 2)

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

abap, actionscript, actionscript3, ada, apache, applescript, apt_sources, asm, asp, autoit, bash, basic4gl, blitzbasic, bnf, boo, c, c_mac, caddcl, cadlisp, cfdg, cfm, cil, cobol, cpp, cpp-qt, csharp, css, d, delphi, diff, div, dos, dot, eiffel, fortran, freebasic, genero, gettext, glsl, gml, gnuplot, groovy, haskell, html4strict, idl, ini, inno, io, java, java5, javascript, kixtart, klonec, klonecpp, latex, lisp, lotusformulas, lotusscript, lua, m68k, matlab, mirc, mpasm, mxml, mysql, nsis, objc, ocaml, ocaml-brief, oobas, oracle8, pascal, per, perl, php, php-brief, plsql, powershell, python, qbasic, rails, reg, robots, ruby, sas, scala, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, verilog, vhdl, visualfoxpro, winbatch, xml, xorg_conf, xpp, z80

 
Personal tools