Pricing plans  Services  API  Partners  About the service  Contacts 
8 (800) 700 7672
Free in Russia
 

Integration with the service (API)

The API allows you to send messages through your projects and services over the HTTP/HTTPS, SMTP, and SMPP protocols. Ready-made libraries in different programming languages connect to your project and help you send messages from anywhere with a single command.


HTTP/HTTPS SMTP SMPP SOAP OMS SMS Commands Libraries and code examples

Examples

Form for sending SMS messages

To send SMS messages from your site, you can use the following example of an HTML form and the corresponding A PHP script that processes the data of this form.


Phone


Message


The sender


Set aside until
(dd. mm. yy hh:mm)

Transliteration Flash-SMS


The source code of the form: <html>
<
form method="post" action="send.php">

Телефон<br/><input name="phone" value=""><br/><br/>

Сообщение<br/><textarea name="message" rows="4" cols="40"></textarea><br/><br/>

Оправитель<br/><input name="sender" value=""><br/><br/>

Отложить до<br/><input name="time" value=""> (дд.мм.гг чч:мм)<br/><br/>

<
input type="checkbox" name="translit">Транслит
<input type="checkbox" name="flash"> Flash SMS<br/><br/>

<
input type="submit" name="send" value="Отправить">
</
form>
</
html>

A send.php file that processes form data and uses the library smsc_api.php: <?
if ($_POST["send"]) {
include_once
"smsc_api.php";

$r = send_sms($_POST["phone"], $_POST["message"],
$_POST["translit"], $_POST["time"], 0,
$_POST["flash"], $_POST["sender"]);

// $r = array(<id>, <количество sms>, <стоимость>, <баланс>) или array(<id>, -<код ошибки>)

if ($r[1] > 0)
echo
"Сообщение отправлено";
else
echo
"Произошла ошибка № ", -$r[1];
}
?>

Phone number confirmation form

To confirm the mobile phone number, for example, when activating a new account on the site , you can use the following example of an HTML form and a PHP script that processes the form data. To avoid sending multiple requests , you can additionally place an anti-spam check (captcha) on the form).


Phone number

Confirmation code 


The source code of the form: <html>
<
form method="post" action="act.php">

<
table>
<
tr><td>Номер телефона<td><input name="phone">
<
tr><td><br/>

<
tr><td>Код подтверждения<td><input name="code" size="6">&nbsp;
<
input type="submit" name="sendsms" value="Выслать код">
<
tr><td><br/>

<
tr><td><input type="submit" name="ok" value="Подтвердить">
</
table>

</
form>
</
html>

A act.php file that processes form data and uses the library smsc_api.php: <?
include_once "smsc_api.php";

if (isset(
$_POST["sendsms"])) {
   
$r = send_sms($_POST["phone"], "Ваш код подтверждения: ".ok_code($_POST["phone"]));

    if (
$r[1] > 0)
        echo
"Код подтверждения отправлен на номер ".$_POST["phone"];
}

if (isset(
$_POST["ok"])) {
   
$oc = ok_code($_POST["phone"]);

    if (
$oc == $_POST["code"])
        echo
"Номер активирован";
    else
        echo
"Неверный код подтверждения";
}

function
ok_code($s) {
    return
hexdec(substr(md5($s."<секретная строка>"), 7, 5));
}
?>

The source code of the form: <html>
<
form method="post" action="act.php" target="ifr">

<
table>
<
tr><td>Номер телефона<td><input name="phone">
<
tr><td><br/>

<
tr><td>Код подтверждения<td><input name="code" size="6">&nbsp;
<
input type="submit" name="sendsms" value="Выслать код">
<
tr><td><br/>

<
tr><td><input type="submit" name="ok" value="Подтвердить"><td colspan="2" id="_out">
</
table>

</
form>
<
iframe name="ifr" frameborder="0" height="0" width="0" style="visibility:hidden"></iframe>
</
html>

A act.php file that processes form data and uses the library smsc_api.php: <?
echo "<script>parent.document.getElementById('_out').innerHTML = '";

include_once
"smsc_api.php";

if (isset(
$_POST["sendsms"])) {
   
$r = send_sms($_POST["phone"], ok_code($_POST["phone"]));

    if (
$r[1] > 0)
        echo
"Код подтверждения отправлен на номер ".$_POST["phone"];
}

if (isset(
$_POST["ok"])) {
   
$oc = ok_code($_POST["phone"]);

    if (
$oc == $_POST["code"])
        echo
"Номер активирован";
    else
        echo
"Неверный код подтверждения";
}

echo
"'</script>";

function
ok_code($s) {
    return
hexdec(substr(md5($s."<секретная строка>"), 7, 5));
}
?>


To avoid multiple confirmation code requests from a single IP address and for one phone number, we recommend that you make the appropriate control on your server. To limit the number of requests per phone number, you can set the appropriate limit in "User Settings". Also, in the confirmation form, it is desirable to add a picture with a code (captcha) to protect against software automatic spam mailings.

Form for confirming the email address

To confirm the email address, for example, when activating a new account on the site , you can use the following example of an HTML form and a PHP script that processes the form data. In order to avoid sending multiple requests , you can additionally place an anti-spam check (captcha) on the form.


E-mail address

Confirmation code 


The source code of the form: <html>
<
form method="post" action="act.php">

<
table>
<
tr><td>E-mail адрес<td><input name="phone">
<
tr><td><br/>

<
tr><td>Код подтверждения<td><input name="code" size="6">&nbsp;
<
input type="submit" name="sendsms" value="Выслать код">
<
tr><td><br/>

<
tr><td><input type="submit" name="ok" value="Подтвердить">
</
table>

</
form>
</
html>

A act.php file that processes form data and uses the library smsc_api.php: <?
include_once "smsc_api.php";

if (isset(
$_POST["sendsms"])) {
   
$r = send_sms($_POST["phone"], "Ваш код подтверждения: ".ok_code($_POST["phone"]), 0, 0, 0, 8, "www@mysite.com", "subj=Confirmation");

    if (
$r[1] > 0)
        echo
"Код подтверждения отправлен на e-mail адрес ".$_POST["phone"];
}

if (isset(
$_POST["ok"])) {
   
$oc = ok_code($_POST["phone"]);

    if (
$oc == $_POST["code"])
        echo
"E-mail адрес активирован";
    else
        echo
"Неверный код подтверждения";
}

function
ok_code($s) {
    return
hexdec(substr(md5($s."<секретная строка>"), 7, 5));
}
?>

The source code of the form: <html>
<
form method="post" action="act.php" target="ifr">

<
table>
<
tr><td>E-mail адрес<td><input name="phone">
<
tr><td><br/>

<
tr><td>Код подтверждения<td><input name="code" size="6">&nbsp;
<
input type="submit" name="sendsms" value="Выслать код">
<
tr><td><br/>

<
tr><td><input type="submit" name="ok" value="Подтвердить"><td colspan="2" id="_out">
</
table>

</
form>
<
iframe name="ifr" frameborder="0" height="0" width="0" style="visibility:hidden"></iframe>
</
html>

A act.php file that processes form data and uses the library smsc_api.php: <?
echo "<script>parent.document.getElementById('_out').innerHTML = '";

include_once
"smsc_api.php";

if (isset(
$_POST["sendsms"])) {
   
$r = send_sms($_POST["phone"], ok_code($_POST["phone"]), 0, 0, 0, 8, "www@mysite.com", "subj=Confirmation");

    if (
$r[1] > 0)
        echo
"Код подтверждения отправлен на e-mail адрес ".$_POST["phone"];
}

if (isset(
$_POST["ok"])) {
   
$oc = ok_code($_POST["phone"]);

    if (
$oc == $_POST["code"])
        echo
"E-mail адрес активирован";
    else
        echo
"Неверный код подтверждения";
}

echo
"'</script>";

function
ok_code($s) {
    return
hexdec(substr(md5($s."<секретная строка>"), 7, 5));
}
?>


To avoid multiple confirmation code requests from a single IP address and for one email address, we recommend that you do the appropriate control on your server. It is also advisable to add a captcha image to the confirmation form to protect against software automated spam mailings.

SOAP Protocol

<?
// Отправка сообщения

$client = new SoapClient ("http://smscentre.com/sys/soap.php?wsdl");
$ret = $client->send_sms(array("login"=>"alex", "psw"=>"123", "phones"=>"79999999999", "mes"=>"Hello world!", "id"=>"", "sender"=>"ivan", "time"=>0));

if (
$ret->sendresult->error)
    echo
"Ошибка №".$ret->sendresult->error;
else {
    echo
$ret->sendresult->id, "\n";
    echo
$ret->sendresult->balance, "\n";
    echo
$ret->sendresult->cost, "\n";
    echo
$ret->sendresult->cnt, "\n";
}


//Flash сообщение от отправителя "ivan", которое должно быть доставлено абоненту 01.01.2012 г. в 00:00:

$ret = $client->send_sms2(array("login"=>"alex", "psw"=>"123", "phones"=>"79999999999", "mes"=>"Hello world!", "id"=>"", "sender"=>"ivan", "time"=>"0101120000", "query"=>"flash=1"));

if (
$ret->sendresult->error)
    echo
"Ошибка №".$ret->sendresult->error;
else {
    echo
$ret->sendresult->id, "\n";
    echo
$ret->sendresult->balance, "\n";
    echo
$ret->sendresult->cost, "\n";
    echo
$ret->sendresult->cnt, "\n";
}


//Несколько сообщений разным абонентам:

$ret = $client->send_sms2(array("login"=>"alex", "psw"=>"123", "phones"=>"", "mes"=>"", "id"=>"", "sender"=>"", "time"=>0, "query"=>"list=79999999999:message1%0A79999999998:message2"));

if (
$ret->sendresult->error)
    echo
"Ошибка №".$ret->sendresult->error;
else {
    echo
$ret->sendresult->id, "\n";
    echo
$ret->sendresult->balance, "\n";
    echo
$ret->sendresult->cost, "\n";
    echo
$ret->sendresult->cnt, "\n";
}


// Получение стоимости

$ret = $client->get_sms_cost(array("login"=>"alex", "psw"=>"123", "phones"=>"79999999999", "mes"=>"Hello world!"));

if (
$ret->costresult->error)
    echo
"Ошибка №".$ret->costresult->error;
else {
    echo
$ret->sendresult->cost, "\n";
    echo
$ret->sendresult->cnt, "\n";
}


// Проверка статуса

$ret = $client->get_status(array("login"=>"alex", "psw"=>"123", "phone"=>"79999999999", "id"=>"999", "all"=>"0"));
    echo
"Ошибка №".$ret->statusresult->error;
else {
    echo
$ret->statusresult->status, "\n";
    echo
$ret->statusresult->last_date, "\n";
    echo
$ret->statusresult->err, "\n";
}


// Расширенный статус

$ret = $client->get_status(array("login"=>"alex", "psw"=>"123", "phone"=>"79999999999", "id"=>"999", "all"=>"2"));
    echo
"Ошибка №".$ret->statusresult->error;
else {
    echo
$ret->statusresult->status, "\n";
    echo
$ret->statusresult->last_date, "\n";
    echo
$ret->statusresult->err, "\n";
    echo
$ret->statusresult->last_timestamp, "\n";
    echo
$ret->statusresult->send_date, "\n";
    echo
$ret->statusresult->send_timestamp, "\n";
    echo
$ret->statusresult->phone, "\n";
    echo
$ret->statusresult->cost, "\n";
    echo
$ret->statusresult->sender_id, "\n";
    echo
$ret->statusresult->status_name, "\n";
    echo
$ret->statusresult->message, "\n";
    echo
$ret->statusresult->operator, "\n";
    echo
$ret->statusresult->region, "\n";
}


// Проверка баланса

$ret = $client->get_status(array("login"=>"alex", "psw"=>"123"));

if (
$ret->balanceresult->balance)
    echo
"Ошибка №".$ret->sendresult->error;
else
    echo
$ret->balanceresult->balance, "\n";

?>



© 2003–2024 SMS Center LLC
support@smscentre.com
Contacts
Design — Artemy Lebedev Studio
Site Information
SMS Center for Android Yandex. Metrica