2-way sms config problems

2-way sms config problems SearchSearch

SMS & MMS Technical Forum » NowSMS Support - SMS Issues (Product Support Only) » Archive through July 14, 2004 » 2-way sms config problems « Previous || Next »
Author Message
Jeff Axup
New member
Username: Axup

Post Number: 2
Registered: 04-2004
Posted on Sunday, May 30, 2004 - 02:05 pm:   

the help documentation doesn't appear to address the 'receive phone number(s):' text box on the '2-way' tab. What does this do?

I'm presuming it only accepts incoming sms's from a given number. I however just tried both the local and international forms of the number of the sending phone, and the server wouldn't process the command in response. The command has been tested and works fine as long as no number is entered in the 'receive phone numbers' text field.

I am trying to get the server to respond selectively to a specific phone number sending an sms, take the contents of that message and then forward it via SMS to a group of numbers. Is there an easier way to do this?

Lars Nielsen, MobileNation ApS - Denmark
New member
Username: Larsmservice

Post Number: 41
Registered: 10-2003
Posted on Sunday, May 30, 2004 - 11:58 pm:   

I think you are presuming wrong.
This is the way i see it work.
Let's say you have 2 modems hooked to nowsms.
They each have a simcard with a mobilenumber on it.
Now you can make 2-way services based on which phone receives the message.
Smart if you have more than one customer or service, etc.

Hope you undestand

Jeff Axup
New member
Username: Axup

Post Number: 3
Registered: 04-2004
Posted on Monday, May 31, 2004 - 10:01 am:   

Hi Lars, thanks for ideas, but I don't think that solution will work for this case.

first of all I don't have an extra phone to use as an additional modem, and additionally, I don't see what I should need additional hardware just to serve a sorting function easily handled by a software script.

basically I need to be able to conditionalize a response based on the content of a message. so for instance if an sms comes from 123-3455 it goes to phones A and B, if it comes from 456-7890 it goes to phones C and D.

I have php installed on my machine, but no web server. what I'd really like to do is either a)use the 2-way SMS command table to filter based on origin phone numbers, or b) pass the contents of the incoming sms to a php script on my machine which processes it, formulates a response and passed it back to nowsms for processing.

i expected the 'receive phone numbers' field might be useful for this, but it doesn't seem to work in any intuitive fashion. I've also tried having nowsms run a .php file which echos back
but it doesn't seem to be processing the result.

has anyone tried conditional routing for sms messages or succeeding in using an external script to process sms content and issue server commands?
Jeff Axup
New member
Username: Axup

Post Number: 4
Registered: 04-2004
Posted on Monday, May 31, 2004 - 11:43 am:   

I should clarify that I do not have a web server running on the machine that nowsms server is installed on. we're at a university and getting web server access and setup involved is very difficult. for this reason we could send an outgoing http request to an apache server I administer, but we have no url to point backwards to the nowsms server on. So in short it is very difficult to get any externally processed command back to nowsms to process.

For this reason we would like to access a local script to do the processing. It might be possible to set up a local apache server on the same machine as nowsms, with no external access, but this seems like a very complex way to get the output of a script to nowsms. Are there any other methods?

currently i'm trying to run the following local php file via the '2-way' 'command to execute' field.

header ("Content-Type: text/plain");
$dest_phone = "0403873529";
$dest_message = "don't you just love getting these messages";
$sms_command = "".$dest_phone."&Text=Group+message+2+".$dest_message;
echo $sms_command;
Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 2714
Registered: 10-2002
Posted on Monday, June 07, 2004 - 09:15 pm:   

Hi Jeff,

Just to clarify the answer on the first point ... the "receive phone number" allows you to setup different scripts based upon the phone number for which a message is received.

So it does not look at the sender of the received message. Instead, it works like Lars describes, it allows you to route received messages to different scripts for different modems (or different SMSC connections).

To do what you want, you'd need to test the value of the sender in your script, and return different results.

I'm not sure how you pass these types of parameters using PHP in command line mode, as PHP expects to run from under the control of a web server.

With some quick tests, I see that I can run a PHP script, and pass parameters to it like this:

c:\php\php.exe c:\temp\test.php Phone=@@Sender@@ Text=@@FULLSMS@@

The PHP script receives the sender in a "Phone" variable, and the text of the message in a "Text" variable.

However, when you run a PHP script like this, it outputs HTTP headers. And NowSMS is not expecting HTTP headers to be returned (and it cannot parse a "Location:" header with a command for sending a message from an executable request).

If you have to work without a separate web server (the web server could be installed on the same machine as NowSMS), Lars did write a very simple script that uses the Windows scripting host, which he uploaded here awhile back:


You might be better off trying to use it rather than PHP, unless you know of a way to disable PHP from generating HTTP headers in its response (I don't).

Jeff Axup
New member
Username: Axup

Post Number: 8
Registered: 04-2004
Posted on Tuesday, June 08, 2004 - 10:27 am:   

Thanks for the clarifications Bryce.
I could use the windows script, however the part that's still confusing me is how to use the script to tell the sms server software to do something.

so Lar's script launches via nowsms, accesses a file and modifies a file. Instead of that, how do I request a new SMS to be sent to number A with content B, via the script, without refering to a url (that is processed by a web server)?

If I echo the "local address" url from a script such as:
does nowsms get that directly?

or do I need to actually call an http function in the script to "run" that url? Is the url the only way to communicate a request to nowsms to initiate sending a new sms?
Jeff Axup
New member
Username: Axup

Post Number: 9
Registered: 04-2004
Posted on Tuesday, June 08, 2004 - 02:11 pm:   

Hi Bryce,
I've given up on using a local script without a web server. I tried running a php script with the redirect, but it wasn't working because there was no web server.
so I've installed a local copy of Apache with integrated php.
I've now got it so I can run: refix=hello&sms_body=justtestingafewthings
from the browser. The php script it runs calls the header redirect and runs the url which sends the SMS through nowsms. very cludgy, but it works.

now here's what's odd:
take exactly the same url and put it into the 2-way SMS command table with variables inserted:
* (all incoming)
when an SMS comes in nothing happens. nothing created in the SMS-IN directory. I've also tried using a url to a remote server that works fine normally, but isn't working through the nowsms command table.

Any idea why it's not processing these urls?
standard sms content return feature works fine...
Jeff Axup
New member
Username: Axup

Post Number: 10
Registered: 04-2004
Posted on Tuesday, June 08, 2004 - 02:53 pm:   

ok, here was the problem:
bug in the command table.
if you have multiple items (each one has to start with different command prefix)
* command
1 command
2 command

the * one will no longer work, but the 1 and 2 ones will. the url i was trying above was the *. it started working when I removed the other two.
Also strange is that you can't set up more than one command per prefix. I'd like to have two different things launched for each message with a certain prefix, but it won't let me enter in multiples.

next question:
does the url syntax support sending to multiple numbers at the same time (in the same url)?
I need to send an sms to multiple people, and the php redirect statement I'm using only works for one url (with one number) and then dies.

I could theoretically get each php script to launch a new php script for each sms, each of which would die... but that would be clunky. any batch capabilities available?
Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 2736
Registered: 10-2002
Posted on Tuesday, June 08, 2004 - 08:42 pm:   

Hi Jeff,

It's hard to do that type of thing via a local script, because there we don't have an approach like the "redirect" approach.

I know you've moved on to using a web server instead. But on the subject of sending an SMS message from Windows script, I do have one more example to share.


The above example creates a new HTTP connection to the NowSMS server to send a message. It doesn't have any 2-way SMS handling logic in it, but that could be added to the script. The example was intended for someone who wanted a command line interface for being able to send an SMS message.

Now, let me get caught up to your follow-up postings.

Regarding the command table, only one command is going to be executed, and it is going to be the one that provides the best match.

For example, let's say you have a command table like this:

* - Command #1
test - Command #2
*@* - Command #3
a* - Command #4

A message that starts with the word "test" is going to trigger command #2.

A message that starts with the word "apple" is going to trigger command #4.

A message that starts with the word "nowsms@now.co.uk" is going to trigger command #3.

A message that starts with the word "sms" is going to trigger command #1.

So, only one command gets triggered, and which one is triggered depends on which one provides the best match.

The URL syntax does allow multiple numbers to be specified in the same URL, just separate the numbers with a comma (,) or semicolon (;).

Also, note that we've got a variety of different PHP examples floating around the discussion forum here. And it's pretty easy to have a PHP script initiate a new HTTP connection back to NowSMS to send a message, so you could easily trigger several different messages to be sent from your PHP script.

Check the second message at the following link:


Basically, you can have your script call the "SendSMS" function from http://support.nowsms.com/discus/messages/1/867.html.

There's another PHP script in the link below, basically one that accepts a couple of variables from a form, and then calls the "SendSMS" function. While it is not a 2-way script, it gives an idea of how the "SendSMS" function can be called from within another script.


Jeff Axup
New member
Username: Axup

Post Number: 11
Registered: 04-2004
Posted on Wednesday, June 09, 2004 - 07:42 am:   

thanks for ideas Bryce. it's now working with local apache web server, local php install.

here's the magic line of php code:
$http_command = "" . $SIM_1_num . "&text=" . urlencode($sms_prefix.$sms_body);
$handle = fopen($http_command, "r");

I haven't tested, but I don't that will work from the local script without web server installed.

So for anyone else trying to do this:
- set the 'two way' command to your local 127.0.0.? address and call a php script
- feed the php script whatever variables you what to use as conditions for sending sms's
- in my case i'm using the sender phone number as a condition to send out batch sms's to a number of other numbers
- for each destination number use above fopen call from the php script, which calls the local url used by the nowsms web interface to send the sms

it may also be possible to send the sms via a fsockopen but the syntax is more complex.

i'd be interested to know if anybody gets the above JS script bryce mentions to run without a web server installed.

in the future it might be cool if nowsms could provide a php library which did a direct connect to the nowsms software (not utilising a web server), so that local scripts could easily communicate with the server without extra software being installed.

Topics Topics Search Last 30 Days Login Login / Register Logout Logout