Solved

How to receive a http post from remote server

Posted on 2008-06-26
4
919 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-
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I really think that i understand this now. Thabks very much
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now