SMSfarm obsahuje SOAP rozhranie, ktoré je štandardom pre integráciu systémov na všetkých platformách SOAP rozhranie môžeš zaintegrovať SOAP na populárnych plaformách ako je PHP, JAVA, Python, Perl, C++, .NET, C#, etc. Stačí, ak nájdeš knižnicu SOAP pre tvoju platformu a napíšeš pár riadkov kódu, ktorými implementuješ náše API..
Bezpečnostné kľúče
Pre využitie nášho API budeš potrebovať dva bezpečnostné kľúče. Integračné ID a Integračné heslo , ktoré nájdeš vo svojom profil.
Taktiež môžeš jednoducho vykopírovať príklady nižšie, ktoré už obsahujú tvoje osobné bezpečnostné kľúče v prípade, ak si už prihlásený.
Podpisový algoritmus
Pomocou jednoduchého ale zároveň mocného algoritmu nebude tvoje heslo nikdy vyzradené. Jeho implementáciu môžeš vidieť v nižších príkladoch
Príklad odoslania správy v jazyku PHP
<?php
// http://www.php.net/manual/en/class.soapclient.php
// Uncomment following line in /etc/php.ini
// extension=soap.so
try {
// one or more recipients separated by comma
$recipient = "+1 800 123 4567";
$code = "sample-code";
$signature = substr(md5($code.$recipient), 10, 11);
$sender = "your ALIAS or PHONE NUMBER";
$values = array(
"integration_id" => "sample-id",
"sender" => $sender,
"recipient" => $recipient,
"message" => "PHP SOAP test using smsfarm.sk API",
"signature" => $signature
);
$client = new SoapClient("https://app.smsfarm.sk/api/?wsdl");
$request_id = $client->SendMessage($values);
print_r($request_id);
// request_id is a unique number, which can be used to obtain delivery status
// wait 1-3 minutes to receive delivery status
// it take few minutes for message to be delivered to cell phone
} catch (Exception $e) {
print_r($e->getMessage());
}
?>
Stav doručenia
Pre získanie stavu doručenia správy, použi procedúruGetMessageStatus a pridaj parametre request_id a number..
<?php
try {
$recipient = "+1 800 123 4567";
$code = "sample-code";
$request_id = '12345'; // output from previous example
// sign request_id parameter
$signature = substr(md5($code.$request_id), 10, 11);
$values = array(
"integration_id" => "${source.integration_id}",
"request_id" => $request_id,
"number" => $recipient,
"signature" => $signature
);
$client = new SoapClient("https://app.smsfarm.sk/api/?wsdl");
$delivery_status = $client->GetMessageStatus($values);
print_r($delivery_status);
// Delivery statuses:
// QUEUED - message is queued and will be sent shortly
// SENDING - message is being sent right now
// SENT - message was sent successfully
// DELIVERED - message was delivered to cell phone
// INVALID-NUMBER - no valid number was supplied in request
// MESSAGE-CANCELLED - message was cancelled by user
// MESSAGE-EXPIRED - delivery time expired
// MESSAGE-UNDELIVERED - message not delivered for unknown reason
// SENT-DELIVERY-UNKNOWN - message was sent, but delivery status is unknown
// COUNTRY-FORBIDDEN - destination country is forbidden, contact us
// SENDING-FAILED - uknown error while sending
} catch (Exception $e) {
print_r($e->getMessage());
}
?>
Časovaná správa
Pre načasovanie odoslania správy v budúcnosti, použi procedúru SendScheduledMessagea pridaj parameter send_time podľa príkladu..
<?php
try {
// one or more recipients separated by comma
$recipient = "+1 800 123 4567";
$code = "sample-code";
$signature = substr(md5($code.$recipient), 10, 11);
$sender = "your ALIAS or PHONE NUMBER";
$values = array(
"integration_id" => "${source.integration_id}",
"sender" => $sender,
"recipient" => $recipient,
"send_time" => date("Y-m-d H:i"),
"message" => "PHP SOAP test using smsfarm.sk API",
"signature" => $signature
);
$client = new SoapClient("https://app.smsfarm.sk/api/?wsdl");
$result = $client->SendScheduledMessage($values);
print_r($result);
} catch (Exception $e) {
print_r($e->getMessage());
}
?>
Pre zrušenie odoslania časovanej správy, ktorá ešte nebola odoslaná, použi procedúru CancelScheduledMessagea pridaj parameter request_id podľa príkladu.
<?php
try {
$code = "sample-code";
$request_id = '12345'; // output from previous example
// sign request_id parameter
$signature = substr(md5($code.$request_id), 10, 11);
$values = array(
"integration_id" => "${source.integration_id}",
"request_id" => $request_id,
"signature" => $signature
);
$client = new SoapClient("https://app.smsfarm.sk/api/?wsdl");
$result = $client->CancelScheduledMessage($values);
print_r($result);
} catch (Exception $e) {
print_r($e->getMessage());
}
?>
Zostávajúci kredit
Pre získanie informácie o zostávajúcom kredite, použi procedúru GetCreditAmount. V tomto prípade podpisuje tvoje integračné ID
<?php
try {
$recipient = "+1 800 123 4567";
$code = "sample-code";
$signature = substr(md5($code.$integration_id), 10, 11);
$values = array(
"integration_id" => $integration_id,
"signature" => $signature
);
$client = new SoapClient("https://app.smsfarm.sk/api/?wsdl");
$result = $client->GetCreditAmount($values);
print_r($result);
} catch (Exception $e) {
print_r($e->getMessage());
}
?>