Link to home
Start Free TrialLog in
Avatar of alzaabi
alzaabi

asked on

nowsms and php

Hi
How can I do this process using nowsms and php

I have local server url return account balances and I need to send an sms to nowsms to retarn the plan text to me cell phone
The url is http://localhost/balance/balance.php?user=xxxxx&password=xxxxxxx 
The prefix well be (balance) the test msg from my phone to nowsms well be

Balance u xxxx p xxxx
=====================
NowSMS Support
You would need to write an additional PHP script (or modify your current script) to perform further parsing of the message.

You could define the following as your 2-way command:

http://localhost/balance/balancesms.php?request=@@SMS@@ 

If you sent in a text as follows:

Balance u xxxx p xxxx

Then the resulting command to be executed would be:

http://localhost/balance/balancesms.php?request=u%20xxxx%20p%20xxxx 

The "%20" looks a little funny in the URL ... but that's just URL escaping. When you access it from your script, your scripting language should convert it back into a space. (The space character needs to be escaped to be included in a URL.)

So the end result is that your script would need to parse the string "u xxxx p xxxx".

You could have a simple PHP script that did this parsing, then redirected to the existing PHP script with the parameters set as needed
======================
I need the php code plz
thanks
Avatar of agsapt
agsapt
Flag of Indonesia image

- Goto "2Way" section of NowSMS
- Tick the "Process incoming SMS" check box
- Add a command into the Received SMS Command Table and put the following valuesr:
         SMS Command Prefix: BALANCE
         Executed Command : http://localhost/balance/balancesms.php?request=@@SMS@@
- Make sure the command return value check box is checked if you want to return some string from your PHP script
- Following is your balancesms.php file

Notes: remember that whatever you print or echo from you PHP script will be returned to the SMS sender


Hope this helps


-=@gS=-
<?
$v = explode(' ', $request);
 
echo $v[0]; // the u character
echo $v[1]; // the username
echo $v[2]; // the p character
echo $v[3]; // the password
 
// here you do what ever you need to do with the user name and password
// for example, you need to query to the database
 
 
print "return message";
 
 
?>

Open in new window

Avatar of alzaabi
alzaabi

ASKER

Dear Sir,
I need Direct Executed Url  (http://global/balance/balance.php?user=xxx&password=xxx)  its return the plan text like $15.00 this url is in global server
How can I  do that using your code in  balancesms.php
Thanks

Avatar of alzaabi

ASKER

final woooooooow its Ok now
<?php
header ("Content-Type: text/plain");
$request=$_GET['request'];
//str_replace("%20"," ",$request)
//print ("$request");
$v = explode(' ', $request);
//echo "$v[0]<br>"; // the u character
//echo "$v[1]<br>"; // the username
//echo "$v[2]<br>"; // the p character
//echo "$v[3]<br>"; // the password
//$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
//echo $url
if ($source = 
file_get_contents("http://127.0.0.1/balance/balance.php?user=$v[1]&password=$v[3]")) {
print $source;
} else {
echo "Could not retrive You Account Or User Name And password Error, please 
contact administrator email@hotmail.com";
}
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of agsapt
agsapt
Flag of Indonesia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial