Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to receive a http post from remote server

Posted on 2008-06-26
4
923 Views
Last Modified: 2013-11-26
Can someone put me on the right path trying to understand what needs to be done to receive a http request from a 3rd party?

My information provider says :
"We will post to you as each message comes in to a URL such as:
http://www.yourserver.com/
receivesms.php?to=TO
&from=FROM&msg=MSG
&date=DATE"

But I want to know how to read this information so that I can add it to a database or dsplay on screen.


0
Comment
Question by:JOHNFROG
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:-Thespian-
ID: 21879621
u need a php hosting on http://yourserver.com/
there u need to have a receivesms.php file with the contens of gathering data and putting it to DB.
if 3rd party company can post data to other url, u need to create page by that url.
for example in php that would be (but it is not safe. it is only example):

<?
$link = mysql_connect('<server>', '<username>', '<password>');
if (!$link) {
  die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db(<database>);
mysql_query("INSTERT INTO `<table>` (`to`, `from`, `message`, `date`) VALUES ('{$_GET['to']}', '{$_GET['from']}', '{$_GET['message']}', 'date')");
?>

Open in new window

0
 

Author Comment

by:JOHNFROG
ID: 21879835
Ok but I'm afraid I am more confused now. I think the example given from the provider is aimed at php developer. I am using ASP.NET so sorry for the confusion.

Just need some clues on where to start. Do I need to create a web service?  If the information is sent to my URL then what do I need to do to process it.
0
 
LVL 5

Accepted Solution

by:
-Thespian- earned 250 total points
ID: 21881430
Than let's say url is "http://www.yourserver.com/receivesms.aspx?to=TO&from=FROM&msg=MSG&date=DATE"
Than u need to create an ASPX page "receivesms.aspx" at the root of the site. with the next contens of "receivesms.aspx.cs" file (have simplified it, due to already u are an ASP.Net developer):


....
protected void Page_OnLoad(...)
{
  string to = Request["to"];
  string from = Request["from"];
  string msg = Request["msg"];
  string date = Request["date"];
 
  DataContext context = new DataContext(connectionString);
  context.ExecuteCommand("INSTERT INTO `<table>` (`to`, `from`, `message`, `date`) VALUES ('"+ to +"', '"+ from +"', '"+msg+"', '"+date+"')");
}
....

Open in new window

0
 

Author Closing Comment

by:JOHNFROG
ID: 31470906
I really think that i understand this now. Thabks very much
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question