Floowie - API

API Structure

Floowie API requests are done to an url http://www.floowie.com/api with HTTP GET parameters. There are 3 basic mandatory parameters for every request. For other parameters please see appropriate request documentation. Parameters don't have mandatory order.

key value
apikey *  contains your API key
action *  defines an action for the request
hash *  contains a security verification for the request, the process of creation is described below

* - mandatory fields

Creating hash 

Hash is a md5 checksum of all of the GET parameters of the URL (everything that follows after "?"), with the exception of the hash parameter itself, appended to the private key.

Hiding user e-mail 

E-mail is a sensitive data of user, and thus has to be kept in secret. All email parameters are required to be encrypted with your Private Key. There's a PHP function for encoding:

function encodeEmail( $email, $privateKey )
{
	$j = 0;
	$hash = '';
	$privateKey = sha1($privateKey);
	$strLen = strlen($email);
	$keyLen = strlen($privateKey);
	for ($i = 0; $i < $strLen; $i++) {
		$ordStr = ord(substr($email,$i,1));
		if ($j == $keyLen) { $j = 0; }
		$ordKey = ord(substr($privateKey,$j,1));
		$j++;
		$hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36));
	}
	return $hash;
}

Example 

Let's assume the following keys:

API key: 9876543210ZYXVWUTSRQPONMLKJIHGFE
Private key: abcdefghijklmnopqrstuwvxyz123456

An e-mail "user@host.com" will be encrypted into z5l474v5k4b4v5o416o274s5j4, thus the request parameters may look as follows:

apikey : 9876543210ZYXVWUTSRQPONMLKJIHGFE
email : z5l474v5k4b4v5o416o274s5j4
format : php
action : prepaidOrder
title : 10
amounttype : 0
amount : 5
date : 978303600

the hash will be calculated as (in terms of PHP):

md5('abcdefghijklmnopqrstuwvxyz123456apikey=9876543210ZYXVWUTSRQPONMLKJIHGFE&email=z5l474v5k4b4v5o416o274s5j4&format=php&action=prepaidOrder&title=10&amounttype=0&amount=5&date=978303600')

which is

e8a44d652e05844bc37cf0f972e18a64

and can be inserted anywhere within the parameters of the URL

 

Output 

The API supports 4 output formats: PHP, json, plain, csv and XML. Default output format is json, but it can be overridden by paramater format in the request. Data in plain format are separated by tab character (\t) and a newline (\n)

key value
lang  language of output and e-mails sent to the user
possible values: en, sk, cs; default: en
format  specifies output format of the data. Possible values: xml, php, json, plain, csv

 

json PHP XML plain csv
{
"key1":"data1",
"key2":"data2"
}
Array
(
 [key1] => data1
 [key2] => data2
)


<response>
<key1>data1</key1>
<key2>data2</key2>
</response>


key1	data1
key2 data2
"key1","key2","key3"
data1a,"data1b",data1c
data2a,data2b,"data2c"

 

If not stated otherwise, the output is either an error code (key 'error') with an error message (key 'message') or a value 'OK' with a key of the action requested.

Array
(
 [order] => OK
)

Array
(
 [error] => 100
 [message] => "Error message"
)