Receive Text Message using php

Receive Text Message using php SearchSearch
Author Message
Kishore
New member
Username: Kishoreavail

Post Number: 1
Registered: 03-2015
Posted on Monday, March 02, 2015 - 07:17 pm:   

My requirement is to send and receive text in php script. I succesfully executed my sending part. But I have trouble in my receiving part.
In 2-way configuraton my Run command is "http://localhost/echo.php&text=@@TEXT@@" and also i specified 'echo' as my Keyword. I don't know where am i going wrong. Can any one help me with this ?

php script :

<?php

header ("Content-Type: text/plain");


if (isset($_REQUEST['text'])) {

$text = $_REQUEST['text'];

echo $text;

}

else {

echo "Invalid request, text= parameter expected.";

}

?>

Thanks in advance !
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5215
Registered: 08-2008
Posted on Monday, March 02, 2015 - 08:05 pm:   

Hi,

Is web server software installed on that same PC?

Can you connect to http://localhost/echo.php&text=@@TEXT@@ from a web browser on that PC?


I am guessing that there is no separate web server installed, and that you are trying to configure NowSMS to run the PHP script directly. In this case, you need to add the NowSMS web port to the URL (e.g., http://localhost:8800/echo.php&text=@@TEXT@@) and echo.php must exist in a subdirectory named PHP under the NowSMS installation directory.

As a suggestion, enable the NowSMS setting "Allow External Web Access to PHP scripts", as this will allow you to test the script from a web browser.

--
Des
NowSMS Support
Kishore
New member
Username: Kishoreavail

Post Number: 2
Registered: 03-2015
Posted on Thursday, March 05, 2015 - 08:28 am:   

yes ! i do have wamp server installed. I can send sms through sendsms.php. If can send the sms through php, y coudn't i receive the text ? Help me with this !
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5217
Registered: 08-2008
Posted on Thursday, March 05, 2015 - 09:19 pm:   

When you type this into a browser, what happens:


http://localhost/echo.php&text=@@TEXT@@

I just want to confirm that the link works.

For further troubleshooting...

1.) Does the "SMS Received" counter increment in the NowSMS stats?

2.) Assuming yes to the above, enable the SMSDEBUG.LOG. Send in another message, and lets see what SMSDEBUG.LOG shows when it tries to process the message.

--
Des
NowSMS Support
Kishore
New member
Username: Kishoreavail

Post Number: 3
Registered: 03-2015
Posted on Friday, March 06, 2015 - 04:42 pm:   

No. Sir.When i try to get into this link "http://localhost/echo.php&text=@@TEXT@@", the response i get is "The requested URL /echo.php&text=@@TEXT@@ was not found on this server."
But when i get into this link "http://localhost/echo.php", Am getting the echo message of else part.

troubleshoot results as u asked :
1) Yes ! SMS Received count got incremented !
2) "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /echo.php&amp;text=Good fun was not found on this server.</p>
<hr>
<address>Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80</address>
</body></html>"

This s the result am getting.
And only some messages are getting received. NOt every message i send to this server !
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5220
Registered: 08-2008
Posted on Friday, March 06, 2015 - 07:06 pm:   

Ah...that explains the problem...you want this:

http://localhost/echo.php?text=@@TEXT@@

? instead of &

For the missing messages, I need a lot more information....starting with....what is your SMSC connection?

--
Des
NowSMS Support
Kishore
New member
Username: Kishoreavail

Post Number: 4
Registered: 03-2015
Posted on Friday, March 06, 2015 - 07:37 pm:   

SMSC connection ? What does that mean ? I am competely new to this !
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5221
Registered: 08-2008
Posted on Friday, March 06, 2015 - 07:40 pm:   

As in, what are you connected to that allows you to send and receive messages?

I'm guessing a modem or phone...if so, what model? Connected via USB or Android phone app?
Kishore
New member
Username: Kishoreavail

Post Number: 5
Registered: 03-2015
Posted on Friday, March 06, 2015 - 07:42 pm:   

Am using HUAWEI modem and the sim inserted to it is IDEA !
Kishore
New member
Username: Kishoreavail

Post Number: 6
Registered: 03-2015
Posted on Friday, March 06, 2015 - 07:44 pm:   

HUAWEI ! model is E303F !
Kishore
New member
Username: Kishoreavail

Post Number: 7
Registered: 03-2015
Posted on Friday, March 06, 2015 - 07:55 pm:   

I tried this "http://localhost/echo.php?text=@@TEXT@@"
Am just getting @@TEXT@@ I would like to do some work systematically with the incoming message. How would i achieve that sir ?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5222
Registered: 08-2008
Posted on Friday, March 06, 2015 - 08:00 pm:   

With Huawei modems, sometimes the software bundled with the modem will remove the received message from the modem before NowSMS can retrieve it from the modem.

Huawei modems are bundled with some associated software called “Mobile Partner”. Sometimes this software is renamed to use a brand from your mobile operator (IDEA).

The Mobile Partner software, by default, will try to process received SMS messages, and may remove these messages from the modem before NowSMS is able to process them. To correct this problem, it is very important that the Huawei Mobile Partner software be configured not to remove received SMS messages from the SIM card. From within Mobile Partner, select Tools/Options/Text Message and ensure that “New Message Save Mode” is set to “Save on SIM/USIM card or device”.

Note that with many different versions of this Huawei software, the option is found in different places, and the wording may change slightly, so it may require looking at all available configuration screens in the modem software.

--
Des
NowSMS Support
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5223
Registered: 08-2008
Posted on Friday, March 06, 2015 - 08:07 pm:   


quote:

I tried this "http://localhost/echo.php?text=@@TEXT@@"
Am just getting @@TEXT@@ I would like to do some work systematically with the incoming message. How would i achieve that sir ?




If you try this in a web browser, the expected response is @@TEXT@@

I'm not sure where your original URL example came from, but it should be

http://localhost/echo.php?text=@@FULLSMS@@

or

http://localhost/echo.php?text=@@SMS@@

@@TEXT@@ is not a valid parameter.

There is a table of valid parameters on this page: http://www.nowsms.com/2-way-commands-for-sms-and-mms-processing-new-2014-feature s

If NowSMS receives a message and connects to the URL, NowSMS replaces @@FULLSMS@@ with the text of the received message. Or @@SMS@@ is replaced with the text of the SMS minus the keyword.

--
Des
NowSMS Support
Kishore
New member
Username: Kishoreavail

Post Number: 8
Registered: 03-2015
Posted on Friday, March 06, 2015 - 08:09 pm:   

Yes ! I did that “Save on SIM/USIM card or device”! Now my question is about handling the received message by reading it and processing it with my php script. For that i woud ike to know the sender's number and his message. how would i do that with NOWSMS ? Please help me with this !
Kishore
New member
Username: Kishoreavail

Post Number: 9
Registered: 03-2015
Posted on Friday, March 06, 2015 - 08:14 pm:   

how to connect NowSMS to url ?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5224
Registered: 08-2008
Posted on Friday, March 06, 2015 - 08:22 pm:   

Using your example, add another variable to pass to the PHP script, like this:

http://localhost/echo.php?text=@@FULLSMS@@&sender=@@SENDER@@

@@SENDER@@ is a replacement parameter that tells NowSMS to insert the sender address.

The PHP script would extract a URL parameter of sender (example $_REQUEST['sender'])

Note in URL format, ? before first parameter, & before parameters after the first.

--
Des
NowSMS Support
Kishore
New member
Username: Kishoreavail

Post Number: 10
Registered: 03-2015
Posted on Friday, March 06, 2015 - 08:51 pm:   

Thanks that worked ! Thank you for your patience these many days !