-
Notifications
You must be signed in to change notification settings - Fork 1
Quick start guide
Martins Pilsetnieks edited this page May 23, 2013
·
3 revisions
The Premium API is a HTTP API which uses HTTP capabilities as much as possible for data exchange, for example, HTTP GET requests for retrieving data, HTTP POST for actions that could potentially alter the data on Premium's side, HTTP POST variables for passing data for such actions. In cases where you could encounter more complicated data structures, JSON encoding is used. All in all, such capabilities should be readily available for most common platforms.
To make an API call you can either craft the HTTP request yourself or use one of our client libraries.
// Instantiating the object with the given API key and campaign code
// $API = new PremiumAPI(APIKey, CampaignCode);
$API = new PremiumAPI('1234567890abcdef', 'demo');
// Submitting the registration
$Message = $API -> Messages_Create(array(
'FirstName' => 'George',
'LastName' => 'Brown',
'ReceiptUnique' => '321/654',
'Phone' => '37121234567'
));
// Checking for registration errors
if ($API -> ErrNo == PremiumAPI::ERROR_BEFORE_CAMPAIGN_START)
{
echo 'Sorry, campaign has not started yet, please try again later!';
}
elseif ($API -> ErrNo == PremiumAPI::ERROR_AFTER_CAMPAIGN_END)
{
echo 'Sorry, campaign has already ended!';
}
// ... other errors could be encountered, too ...
elseif (!$API -> ErrNo)
{
// Everything's ok
print_r($Message);
}
else
{
echo 'Something went wrong with the registration';
}
The array in the Messages_Create
call should contain the relevant variables for the campaign.
Other error codes can be found here.