Sending and receiving HTTP responses

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DrCrispy
Forum Newbie
Posts: 2
Joined: Thu Aug 14, 2008 11:01 am

Sending and receiving HTTP responses

Post 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
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Sending and receiving HTTP responses

Post 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!
DrCrispy
Forum Newbie
Posts: 2
Joined: Thu Aug 14, 2008 11:01 am

Re: Sending and receiving HTTP responses

Post by DrCrispy »

Thanks nowaydown1

Appreciate the response.

I'll give it a go.

8)
Post Reply