Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to receive a http post from remote server

Posted on 2008-06-26
4
Medium Priority
?
930 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 1000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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.

885 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