How to send HTTP request using PHP?

There is a predefined php class called HttpRequest. By using this class we can create object for handle HTTP requests. There are list of function to handle it. Refer PHP manual and get some idea about this class.


In WAMP before use this objects you need to make some changes in php.ini file. Add following line into the php.ini file (somewhere near in the extension).
“extension=php_http.dll”
Example
======
user HttpRequest object to handle get method http request
$r= new HttpRequest(‘www.example.com?valueone=1&valuetwo=2’, HttpRequest::METH_GET);
$r->send();
echo $r->getResponseBody();
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: