Fortumo Mobile Payments / Premium SMS API technical specification
Mobile Payments / Premium SMS API is the most flexible service type in Fortumo. It allows you to create practically any SMS service, that you could think of, but it requires some programming skills and a web-server where you could host your program (for example as a PHP-script). Interaction between our server and your script will be conducted with HTTP GET requests. There are three possible types of HTTP requests, which are described below. The parameters present in these requests are always the same. The most important and obligatory in message processing is the first type.
Parameters
messagesendercountrypricecurrencyservice_idmessage_idkeywordshortcodeoperatorbilling_typestatuspending(in message delivery request), ok or failed(in billing report).testsigPeople usually need only message and perhaps sender parameters, but for more advanced uses we have also added others.
It is important to make sure that the service script is called by Fortumo and not someone else. There are several security measures, that satisfy most of the service providers:
$_SERVER["REMOTE_ADDR"] variable.
sig parameter and is calculated as md5 checksum of the request parameters and secret concatenated together. You can make the same calculation and check whether the sig parameter in the request matches the one that you calculated. See the PHP example below to find out exactly how the calculation is made.
Sample sms.php
<?php //set true if you want to use script for billing reports //first you need to enable them in your account $billing_reports_enabled = false; // check that the request comes from Fortumo server if(!in_array($_SERVER['REMOTE_ADDR'], array('81.20.151.38', '81.20.148.122', '79.125.125.1', '209.20.83.207'))) { header("HTTP/1.0 403 Forbidden"); die("Error: Unknown IP"); } // check the signature $secret = ''; // insert your secret between '' if(empty($secret) || !check_signature($_GET, $secret)) { header("HTTP/1.0 404 Not Found"); die("Error: Invalid signature"); } $sender = $_GET['sender']; $message = $_GET['message']; $message_id = $_GET['message_id'];//unique id //hint:use message_id to log your messages //additional parameters: country, price, currency, operator, keyword, shortcode // do something with $sender and $message $reply = "Thank you $sender for sending $message"; // print out the reply echo($reply); //customize this according to your needs if($billing_reports_enabled && preg_match("/Failed/i", $_GET['status']) && preg_match("/MT/i", $_GET['billing_type'])) { // find message by $_GET['message_id'] and suspend it } function check_signature($params_array, $secret) { ksort($params_array); $str = ''; foreach ($params_array as $k=>$v) { if($k != 'sig') { $str .= "$k=$v"; } } $str .= $secret; $signature = md5($str); return ($params_array['sig'] == $signature); } ?>Copy to clipboard