Support for

FLAPI: Format for requests

Alistair Wilson
by Alistair Wilson 5 years ago
 

Sandbox and documentation site, to help you test

At https://dev.flyerlink.com/api.php/, we provide a sandbox for API requests, which documents the API requests, along with convenient entry forms where you can specify values for parameters..

Request format

Use standard HTTP requests to communicate with the API.

GET requests are used to read data from TemplateCloud using the API;

PUT and POST requests try to write information to TemplateCloud using the API.

The following example is a request to the API’s sandbox handler, which returns a list of tag types:

HTTP request
GET https://dev.flyerlink.com/api.php/tag_types/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json

You have the option of specifying the response format using the format parameter. Allowed values are json or xml, the default being xml.

When sending a POST or PUT request, we expect them as HTTP form fields
You can push them through as an array
Here's an example of a POST customer request

<?php

$postFields = [
"id" => "HOTEST",
"name" => "Jean TEST",
"username" => "API example",
"password" => "example1234",
"email" => "bbb@test.com",
"telephone" => "01470054111",
"mobile" => "0674584511",
"address1" => "",
"address2" => "Your Address",
"address3" => "",
"address4" => "Manchester",
"address5" => "",
"postcode" => "M17 1AA",
"countrycode" => "GB",
"workgroup" => "W11",
"category" => "816",
"payment_terms_code" => "CASH",
"payment_terms_description" => "Cash"
];

$s = curl_init();
$username = 'xxx';
$password = 'xxx';

curl_setopt($s, CURLOPT_URL, 'http://dev-7.flyerlink.com/api.php/customers');
curl_setopt($s, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($s, CURLOPT_RETURNTRANSFER, true);
curl_setopt($s, CURLOPT_POST, true);
curl_setopt($s, CURLOPT_POSTFIELDS, $postFields);

$result = curl_exec($s);
$resstatus = curl_getinfo($s, CURLINFO_HTTP_CODE);
curl_close($s);

var_dump($result);
var_dump($resstatus);

You’ll need your own user_key (see Getting your App Approved).

Response format

Error (response code 404)

HTTP response (JSON)
{
  "status": "error",
  "message": "Template not found"
}

Success (response code 200) 

Where one record is returned, it is presented as a lone object, e.g.

HTTP request
GET https://dev.flyerlink.com/api.php/tag_types/1?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
HTTP response (JSON)
{
    "tag_type": {
        "id": "1",
        "name": "Industry Types"
    }
}

Where more than one record is returned, the top-level object is an array (having a plural name tag_types), containing child tag type objects. 

e.g. here are the requests and responses for tag types

HTTP request
GET https://dev.flyerlink.com/api.php/tag_types/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
HTTP response (JSON)
{
    "tag_types": [
        {
            "id": "1",
            "name": "Industry Types"
        },
        {
            "id": "2",
            "name": "Client"
        },
        etc...
    ]
}

XML format

The XML version is below. Note that the above JSON does not encapsulate the array's items as named objects, but the XML necessarily does: 

HTTP request
GET https://dev.flyerlink.com/api.php/tag_types/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=xml
HTTP response (XML)
<response status="ok">
    <tag_types>
        <tag_type>
            <id>1</id>
            <name>Industry Types</name>
        </tag_type>
        <tag_type>
            <id>2</id>
            <name>Client</name>
        </tag_type>
etc...
    </tag_types>
</response>    

POST responses

  • Currently, responses to POST requests are only returned in XML format.
  • Remember to format POST requests by inserting a new line between the path and the parameters. See examples.
 

See also

Getting your App Approved

Jump to contents page of

Flyerlink API Guide

 
 
 

All content is (c) Nettl Systems Limited, 2024 and may not be used, copied or distributed without permission.