Community discussions

MikroTik App
 
David1234
Forum Guru
Forum Guru
Topic Author
Posts: 1424
Joined: Sun Sep 18, 2011 7:00 pm

sending SMS from computer via mikrotik RB?

Tue May 28, 2013 9:19 am

Hello,
I want to know if it is possible to send a command from the computer to send SMS ?
does it make sence what I want?
 
User avatar
ohara
Member
Member
Posts: 387
Joined: Mon Jun 13, 2011 11:30 pm
Location: Warsaw

Odp: sending SMS from computer via mikrotik RB?

Tue May 28, 2013 9:30 am

Yes it is possible in many ways. You can do it with winbox, ssh or php api. You could even develop your own sms sender application with .net and api.
 
rainmaker
Frequent Visitor
Frequent Visitor
Posts: 65
Joined: Fri Jan 30, 2009 9:32 pm

Re: sending SMS from computer via mikrotik RB?

Tue May 28, 2013 2:14 pm

yes but how can l do that.
Currently using sms service provider.

how to l modified the following api to work with sending sms using Mikrotik.
Thanks



<?php
/*****************************************************************************
** Name: api_sendsms
**
** Description: This function is used to send a SMS messages to a mobile phone.
** You can call your SMS gateway to send a message to a mobile phone.
** The function includes an example code of integrating the
** clickatell.com HTTP -> SMS gateway.
**
** >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
** Syed Jahanziab > I have changed it to use my local sms gateway running on KANNEL , Configured on same box where RM is installed and connected TELTONIKA GSM MODEM with it in VM.
** >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
**
** Input: $mode - SMSMODE_ACCVERIFY: send verification code
** SMSMODE_WELCOME: send account data
** SMSMODE_PSWCODE: send new password activation code
** SMSMODE_NEWPSW: send new password
** $username - RADIUS user name
** $password - RADIUS password
** $firstname - first name of user
** $lastname - last name of user
** $address - postal address of user
** $city - city of user
** $zip - zip code of user
** $country - country of user
** $state - state of user
** $phone - phone number of user
** $mobile - mobile number of user
** $email - email address of user
** $srvid - associated service id
** $verifycode - the verification code to send
** $errmsg - pointer to error message returned by the gateway
**
** Output: True if API succeeded or false
*****************************************************************************/
function api_sendsms($mode, $username, $password, $firstname, $lastname, $address, $city, $zip, $country, $state, $phone, $mobile, $email, $srvid, $verifycode, &$errmsg)
{
// enter your local sms http gateway credentials here

$api_user = "kannel";
$api_password = "kannel";

switch ($mode)
{
case SMSMODE_ACCVERIFY:
$body = "Enter the following verification code in Client service Center: $verifycode";
break;

case SMSMODE_WELCOME:
$body = "Welcome new user! Your user name is $username, your password is $password";
break;

case SMSMODE_PSWCODE:
$body = "New password activation code: $verifycode";
break;

case SMSMODE_NEWPSW:
$body = "Your new password: $password";
break;
}

// return success (uncomment the following lines in testing environments only)

// print $body;
// return true;

// implement your own SMS gateway in the following block

$body = rawurlencode($body);
$ch = curl_init();
// change the IP and id password in the below line to match your local config. syed jahanzaib
curl_setopt($ch, CURLOPT_URL, "http://1.1.1.1:13013/cgi-bin/sendsms?us ... text=$body");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
curl_close($ch);

// uncomment this to see the result from clickatell.com HTTP->SMS gateway

// print $res;

if (substr($res, 0 , 4) == "ERR:")
{
$errmsg = $res;
return false;
}

// SMS sent successfully

return true;
}
?>
 
User avatar
ohara
Member
Member
Posts: 387
Joined: Mon Jun 13, 2011 11:30 pm
Location: Warsaw

Re: sending SMS from computer via mikrotik RB?

Tue May 28, 2013 10:51 pm

rainmaker, the script which you copied was not intended to be used with mikrotik. These two links will give you more details, please review and if you'll have further questions feel free to ask:

http://forum.mikrotik.com/viewtopic.php ... it=sms+api (PHP)
http://blog.getcaffeinated.net/2011/08/ ... s-gateway/ (PERL)

Who is online

Users browsing this forum: No registered users and 176 guests