-
Kā darbojas Individuālais īsziņu pakalpojumus?
Individuālais īzsiņu pakalpojums ir viselastīgākais Fortumo pakalpojuma veids. Tas ļauj radīt praktiski jebkuru īsziņu pakalpojumu, ko vien vari iedomāties, bet, lai to izdarītu, ir nepieciešamas programmēšanas iemaņas un web-serveris, kur tu vari vadīt savu programmu (piemēram, PHP-skripts).
Kad tavs pakalpojums saņem īsziņu, Fortumo izdara HTTP GET pieprasījumu URL adresei, ko Tu esi norādījis pakalpojuma uzstādījumos (piemēram, http://yourdomain.com/sms.php). Saturs, ko Fortumo saņem no tavas URL (vai tā pirmās 120 zīmes) tad tiek nosūtītas atpakaļ lietotājam atbildes ziņā. HTTP GET pieprasījuma parametric norāda lietotāja telefona numuru, ziņas saturu utt. Tā kā tu vari pielietot visu informāciju, lai izveidotu atbildes ziņu.



-
Parametri
message- Ziņas saturs mīnus atslēgas vārds. Ja ziņas teksts ir TXT KEY 123, tad šis parameters ir 123. Parametrs ir tukšs, ja ziņā ir nosūtīts tikai atslēgas vārds bez papildus teksta.
sender- Ziņas sūtītāja telefona numurs internacionālajā formātā bez plusa zīmes. Piemēram, 4560123456 vai 358401234567.
country- Sūtītāja mobilā operatora valsts kods. Divu zīmju kodi tiek lietoti saskaņā ar ISO 3166-1 standartu (SE Zviedrijai, FI - Somijai, NO - Norvēģijai, LT - Lietuvai, LV - Latvijai, EE - Igaunijai utt). Lūdzu atceries, ka tā var arī NEBŪT patiesā sūtītāja atrašanās vieta. Piemēram, lietotājs ar Zviedrijas telefonu var sūtīt īsziņu, kamēr viņš klejo Norvēģijā - Tev joprojām tiks uzrādīts SE valsts lauciņā.
price- Galalietotāja cena par īsziņu vietējajā valūtā, ieskaitot PVN.
currency- Vietējās valūtas symbols, atsaucoties uz ISO 4217 (EUR, SEK, NOK, DKK, LTL, LVL, EEK, USD, GBP utt).
service_idstring, kas identificē šo Fortumo pakalpojumu. Piemēram, f7fa12b381d290e268f99e382578d64a. Ja Tev ir daudzi pakalpojumi ar vienādu URL, tad Tu vari lietot šo lauciņu, lai noteiktu kuram pakalpojumam īsziņa ir domāta.message_idstring, kas ir unikāla katrai ziņai, ko saņem tavs pakalpojums.keyword- Atslēgas vārds ir daļa no īsziņas. Tomēr, ja ziņas teksts ir TXT KEY 123, tad šis parameters ir TXT KEY.
shortcode- Īsais kods, uz kuru tiek nosūtīta īsziņa.
operator- Name of the sender's mobile network operator.
billing_type- Can be MO or MT. Read more about billing types in Fortumo FAQ.
status- Billing status, which is either
pending(in message delivery request),okorfailed(in billing report). test- This parameter is present only when message is sent through Fortumo testing interface by yourself and it's value is always 'true'.
sig- Request signature that you may check, to make sure the request is originating from Fortumo. See below under Security to find out how.
Cilvēkiem parasti ir nepieciešama tikai
messageun varbūtsenderparametri, bet vairāk uzlabotai lietošanai mēs esam pievienojuši arī citus.


-
Security
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:
-
Pārbaudi vai servera IP adrese, kas dod pieprasījumu pieder vienam no Fortumo serveriem. Mūsu pašreizējās IP adreses ir: 81.20.151.38, 81.20.148.122 un 209.20.83.207. Ja tās mainīsies, mēs tev dosim ziņu pa e-pastu. PHP Tu vari to pārbaudīt ar$_SERVER["REMOTE_ADDR"]mainīgo. -
Izvēlies sarežģītāku direktorijas vai skripta nosaukumu. Piemēram: http://yourdomain.com/sms.php nav tik labs kā http://yourdomain.com/go850g3oigjrtog/sms.php. -
Check that the attached signature matches. All the requests are signed with the shared secret only known to you and Fortumo. You can see the secret from the service settings page. The signature is added assigparameter and is calculated as md5 checksum of the request parameters and secret concatenated together. You can make the same calculation and check whether thesigparameter 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', '209.20.83.207'))) { die("Error: Unknown IP"); } // check the signature $secret = ''; // insert your secret between '' if(!empty($secret) && !check_signature($_GET, $secret)) { die("Error: Invalid signature"); } $sender = $_GET['sender']; $message = $_GET['message']; // 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); } ?>
Pārkopēt uz glabātuvi





