|
While there are multiple ways to perform HTTP on PHP, such as sockets and CURL, these leave something to be desired. We have found that the PECL library php_http.dll available through php.net is an excellent HTTP wrapper for win32 systems. At the time of this writing, the current verison of PHP was 5.2.8, however there was an issue with the hosting of the win32 compiled libraries, so the current version was pecl 5.2.6. To install this library, download the zip file pecl-5.2.6-Win32.zip, and extract the dll php_http.dll to your PHP extensions directory (e.g. c:\php\ext) then add the extension to your php.ini library (search for your exsiting extensions in this file). Here is a basicHTTP Get function accomplished with this PHP extension: public function GetFromURL($url){ $response = http_get($url, array("timeout"=>30), $info); $body = http_parse_message($response)->body; if($responseCode != $info['response_code']){ throw new Exception("Error Posting to ".$url.". Response Code: ".$info['response_code']); } return $body; } For full documentation on this HTTP library see: http://www.php.net/manual/en/book.http.php
|