Need help with data inqury using nowsms

Need help with data inqury using nowsms SearchSearch
Author Message
Kenny Han Jong Kwong
New member
Username: Kenny_h

Post Number: 3
Registered: 03-2009
Posted on Sunday, March 08, 2009 - 12:27 pm:   

Hello everyone,

I am currently doing some project which you can get an account information by sending sms.

Its like this, lets say you send "INFO 123456" to the server, the 'INFO' is the sms command prefix for getting the account information and 123456 is the account number, then server may execute the command and compare the account number sent in the sms with the account number in the database. And if the comparison match it will then send a reply back to sender with a sms containing all the user's information like name, address etc.

Can anyone help me with this?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 564
Registered: 08-2008
Posted on Monday, March 09, 2009 - 05:53 pm:   

Hi Kenny,

Before I get into the NowSMS specific configuration, let me explain what NowSMS expects from you in this scenario.

NowSMS expects that you can provide either a URL link or a local executable program that NowSMS can send the the account number to, and receive back a text response to be sent back in response to the inquiry.

For example, you might have a PHP script where if you make this request http://ip/acctinfo.php?no=123456, the script returns a text response with account information. (Most likely you're also going to want to include the phone number of the requestor in the link to use that as some sort of additional security so that people aren't making inquiries about accounts belonging to others ... but this is the basic idea.)

In NowSMS, you configure a 2-way command that is template based ... such as http://ip/acctinfo.php?no=@@SMS@@ ... and NowSMS replaces the template variables with information from the received SMS.

Here are some links to additional information to help you get started...

First, a general overview of 2-way SMS .... http://www.nowsms.com/documentation/ProductDocumentation/2_way_sms_support.htm

And, here's some practical examples written in PHP ... http://support.nowsms.com/discus/messages/1/4520.html

--
Des
NowSMS Support
Kenny Han Jong Kwong
New member
Username: Kenny_h

Post Number: 5
Registered: 03-2009
Posted on Friday, April 03, 2009 - 01:19 am:   

Thanks for the help.

And there's one more thing i would wanna know.
Lets say i add a PIN number for security.

Like, "INFO 123456 789" where "789" is the PIN number.

For the command "http://ip/acctinfo.php?no=@@SMS@@", what more i need to add to the command for PIN, as i cant use "pin=@@SMS@@".
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 656
Registered: 08-2008
Posted on Friday, April 03, 2009 - 03:33 pm:   

Hi Kenny,

You'd have to do your own parsing of the input string.

For example ... think of the following command:

"http://ip/acctinfo.php?str=@@SMS@@"

Your PHP script would parse the "str" variable to look for whatever information you require.

--
Des
NowSMS Support
Kenny Han Jong Kwong
New member
Username: Kenny_h

Post Number: 6
Registered: 03-2009
Posted on Friday, April 03, 2009 - 04:01 pm:   

Dear Des,

Can u show one simple example please?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 657
Registered: 08-2008
Posted on Friday, April 03, 2009 - 04:26 pm:   

Kenny,

Assuming that you're working in PHP, you'd probably want to use the strtok function.

strtok is documented here:

http://us2.php.net/manual/en/function.strtok.php

Let's take this example 2-way command again:

"http://ip/acctinfo.php?str=@@SMS@@"

In a PHP script, you would retrieve the "str" variable with a statement like this:

$str = $_REQUEST['str'];

You can then use the strtok function to parse the individual words from the string, like in the example from the PHP manual that I linked to above.

Here's a simple example that only parses the first 3 "words" in a string into separate variables:

$str = $_REQUEST['str'];

$firstword = NULL;
$secondword = NULL;
$thridword = NULL;

$tok = strtok($str, " \r\n\t");

if ($tok != false) {
$firstword = $tok;
$tok = strtok(" \r\n\t");
}

if ($tok != false) {
$secondword = $tok;
$tok = strtok(" \r\n\t");
}

if ($tok != false) {
$thirdword = $tok;
$tok = strtok(" \r\n\t");
}


I didn't test any of the above script, so I might have made a stupid error, but if I did, it should be close to working.

--
Des
NowSMS Support