NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP equivalent of the XMLHTTP Library ?

Dell Sala dell at sala.ca
Tue Jun 12 11:07:20 EDT 2007


On Jun 12, 2007, at 9:31 AM, Miretsky, Anya wrote:

> I am trying to  retrieve and send data to a remote web server using  
> HTTP. [...] Can anyone point me in the right direction?

There are a few ways to do it...

For simple GET requests the easiest is to use file functions that  
support the HTTP protocol, like fopen() or file(). (The php.ini  
setting allow_url_fopen must be enabled for this to work). EX:

$responseLines = file('http://google.com/');

more details: http://us.php.net/manual/en/features.remote-files.php

For POST request you'll need to use either the curl, or socket  
functions.

http://us.php.net/manual/en/ref.curl.php
http://us.php.net/manual/en/function.fsockopen.php

PEAR also has an HTTP_Request package. This uses the socket functions  
internally, but is much simpler to work with.

http://pear.php.net/package/HTTP_Request

Hope this helps.

-- Dell





More information about the talk mailing list