Page 1 of 1

Sending and receiving HTTP responses

Posted: Thu Aug 14, 2008 11:08 am
by DrCrispy
Hi all

First post yipee!

See if you can help me....

I am currently writing a PHP application that talks to an API for logging in, account management etc.

The API accepts a POST request and generates a plain text, name/value pair response like this:

status=ok
username=bob
last-login=01.01.2000

etc....

How can I send and read the response using PHP?

Can someone point me in the right direction for sending the request and parsing the responses?

Any help appreciated

Cheers

Re: Sending and receiving HTTP responses

Posted: Thu Aug 14, 2008 1:00 pm
by nowaydown1
Hi Crisp,

Welcome to the forum. There's a few different approaches for this kind of thing. My recommendation would be to have a look at the CURL library (http://us3.php.net/manual/en/function.curl-init.php). It can construct POST requests. The library is primarily used for posting data to / getting data from remote websites.

For what you're trying to do you'll probably have to have a few curl_setopt() calls, but the manual has info on that too.
(http://us.php.net/curl_setopt)

Good luck!

Re: Sending and receiving HTTP responses

Posted: Tue Aug 19, 2008 2:23 am
by DrCrispy
Thanks nowaydown1

Appreciate the response.

I'll give it a go.

8)