SMShub and custom sms gateway.

974 views
Skip to first unread message

Nick Hoekman

unread,
Oct 8, 2013, 4:39:45 AM10/8/13
to rcdevs-t...@googlegroups.com
We are testing out OpenOTP in our company.. before buying it for 100 users. 

But we have a issue with smshub config for sending out tokens by sms. 

i can't seem to figure out how i can send it through a http post sms gateway we running. 


http://10.85.200.1/sendsms? is the url of local sms gateway but i need post variables like: 

phone="users phone number"&text="Token and text need to be here"&password="password"


Can someone help me out how i can get this to work?


Administrators

unread,
Oct 8, 2013, 6:48:03 AM10/8/13
to rcdevs-t...@googlegroups.com
You need a OpenOTP SMShub configured and you need to make a custom SMSC connector in SMSHub:


Nick Hoekman

unread,
Oct 8, 2013, 7:53:42 AM10/8/13
to rcdevs-t...@googlegroups.com
Hello thanks for the reply. 

Yes i saw the documentation, tried the things in the documentation with the custom1-4.php in /opt/webadm/websrvs/smshub/smsc

But i can't get it to work, i think i just don't understand how it works. 


Can u please help me on the right way, can u give me a example on how it needs to be done.. with the information i gave u?

would be appreciated 

Op dinsdag 8 oktober 2013 12:48:03 UTC+2 schreef Administrators:

Administrators

unread,
Oct 8, 2013, 8:45:42 AM10/8/13
to rcdevs-t...@googlegroups.com
It very simple:

The custom script contains a function like 
    function smshub_custom1 ($msg, $mobile, $flash, $sender, $username, $password, $account, $url, $proxy, &$error) {...}

This function is called by SMSHub to send the SMS. The call will receive all the parameters.
Ex: $mobile will contain the user mobile number and $msg will contain the SMS message to be sent.

Just drop all the content of the function and add your own PHP code to send the $msg to $mobile with your custom SMSC service.
If, like you say, it's a simple call to a URL with parameters, just use CURL PHP to make an HTTP GET request to the service.

Ex.
$ch = curl_init("http://10.85.200.1/sendsms?phone=".urlencode($mobile)."&text=".urlencode($msg));
$result = curl_exec($ch);
curl_close($ch);

Note that some of the parameters are the SMSC settings which you configure in the SMSHub graphical configuration in WebADM.
Ex : password, username, sender, url...
So you can put your custom SMSC login password in the graphical config and use the parameter. Same for the URL.

Note that the custom function must return a "true" on success.

Be sure to read and follow the SMSHub README to correctly configure OpenOTP and SMSHub to work together.
OpenOTP calls SMSHub service to send the SMS. there is a login with a static username/password to be set in SMSHub configuration and in OpenOTP. Then if SMSHub is configured with a Custom SMSC, it will call your script.

Nick Hoekman

unread,
Oct 9, 2013, 4:46:59 AM10/9/13
to rcdevs-t...@googlegroups.com
Thanks for detailed information. 

do i need to add the example to a need php file or edit a custom file and leave some in it ?

best regards

Op dinsdag 8 oktober 2013 14:45:42 UTC+2 schreef Administrators:

Administrators

unread,
Oct 9, 2013, 7:34:06 AM10/9/13
to rcdevs-t...@googlegroups.com
You just need to edit the custom1.php file.
Your custo will remain even after an upgrade.

Customize the end of the script below:

function smshub_custom1 ($msg, $mobile, $flash, $sender, $username, $password, $account, $url, $proxy, &$error) {
    $options = array(
     CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_SSL_VERIFYPEER => false,
                     CURLOPT_SSL_VERIFYHOST => false
    );
    
    // set HTTP proxy connection (if any)
    if ($proxy) {
$options[CURLOPT_PROXY] = $proxy['host'].":".$proxy['port'];
if ($proxy['user'] != NULL && $proxy['password'] != NULL) {
   $options[CURLOPT_PROXYUSERPWD] = $proxy['user'].':'.$proxy['password'];
}
    }
    
    // default URL if not set in SMSHub configuration
    if ($url == NULL) $url = "http://10.85.200.1:9090/sendsms";
    $url .= '?phone='.urlencode($mobile);
    $url .= '&text'.urlencode($msg);
    $url .= '&password='.urlencode($password);
    
    // call with CURL
    $ch = curl_init($url);
    if (!$ch) {
$error = "curl_init() failed";
return false;
    }
    
    if (!curl_setopt_array($ch, $options)) {
$error = "curl_setopt_array() failed";
curl_close($ch);
return false;
    }
    
    $ret = curl_exec($ch);
    if (curl_errno($ch)) {
$error = curl_error($ch);
curl_close($ch);
return false;
    } else {
websrv_debug("SMSC returned $ret");
    }
    curl_close($ch);
    
    // dont't know what is return
    // something like this but you need to check
    if ($ret == "Ok") return true;
    else return false;
}

Nick Hoekman

unread,
Oct 11, 2013, 5:35:39 AM10/11/13
to rcdevs-t...@googlegroups.com
I can't get it to work.. tried every possible settings in OTP and SMSHub 

keep getting error Server error (could not send SMS password to +31 6

Best regards, 
Nick

Op dinsdag 8 oktober 2013 10:39:45 UTC+2 schreef Nick Hoekman:

Nick Hoekman

unread,
Oct 16, 2013, 2:50:32 AM10/16/13
to rcdevs-t...@googlegroups.com
Still have same problem, can someone help me out.. if we don't get it working, then we must look for a other solution.

best regards, 
Nick

Op vrijdag 11 oktober 2013 11:35:39 UTC+2 schreef Nick Hoekman:

Administrators

unread,
Oct 16, 2013, 5:07:44 AM10/16/13
to rcdevs-t...@googlegroups.com
Without more information there is nothing where we can help.
Maybe you can provide us an access to your SMSC service. Then we can debug. 

Nick Hoekman

unread,
Oct 16, 2013, 6:34:18 AM10/16/13
to rcdevs-t...@googlegroups.com
That is possible, maybe a teamviewer session a solution? if so how can i give you the information?

Best regards, 
Nick

Op woensdag 16 oktober 2013 11:07:44 UTC+2 schreef Administrators:
Reply all
Reply to author
Forward
0 new messages