tags:

views:

90

answers:

1

Hi, we need to send an http post from an iphone device to our server with some info which the device token (APNS) which we want to store. How on the server do you read the HTTP post and store what is in it? We just have a standard ISP hosted server which currently just has a website.

Thanks

+1  A: 

There are many ways you could do this. You probably want to store the values in a database. Your hosting account probably has databases. Find out what database software is installed. The chances of it being MySQL http://www.mysql.com/ are high.

Depending on what you want to do with the data, a simple PHP http://php.net/index.php script that accepts POST data, parses and checks it would be fine. However, be careful. You should do some kind of authentication prior to inserting the data into the database. Or maybe the value you are sending to the server is already encrypted and you can verify it that way.

You could also use Perl, Python, Ruby, etc. It depends on what your host supports.

sims
Hi, thanks. Would this PHP script need to monitor HTTP port continuously , ie listen on this port
tech74
That is the job of Apache or whatever webserver you are running. It listens on the specified port. When a request comes for your script, the script is run. If you have access to your servers config files, then you can have it listen on almost any port you like. Of course your host may not allow this. Though it does make sense to use an obscure port, it may be a bad idea, as the various networks around the world that the iPhone is deployed on may also have some restrictions to what ports are accessible. You probably want to research that a bit.
sims
Thanks, i didn't understand this statement ""When a request comes for your script,your script is run"How do i make a request come for my script, the client will just be sending a POST, how does it target the script?Thanks
tech74
The request comes *FOR* your script, not *FROM* you script. The request comes from the client(iphone) not the server. The server responds to the request.This is very basic http stuff. When you type http://domain.com/mycoolscript.pl into your browsers address bar and press enter on the keyboard, the browser will request mycoolscript.pl from domain.com.How you send the request and post data from your iphone is up to you.
sims