Modern answer for MAMP 2.0 and HTTP_Request2:
Log in to your MAMP / bin / php / php5.3.6 / bin / and run
./pear install --alldeps HTTP_Request2
Reboot your server and test it using the following code from the PEAR repository:
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2('http://pear.php.net/', HTTP_Request2::METHOD_GET);
try {
$response = $request->send();
if (200 == $response->getStatus()) {
echo $response->getBody();
} else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
} catch (HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
Do not forget the require_once statement!
source
share