Solved

How to receive a http post from remote server

Posted on 2008-06-26
4
924 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

740 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