<?php
require_once 'Zend/Http/Client.php';
try {
$http = new Zend_Http_Client('http://example.org');
$response = $http->get();
if ($response->isSuccessful()) {
echo $response->getBody();
} else {
echo "<p>发生错误</p>\n";
echo "HTTP Status: " . $response->getStatus() . "\n";
echo "HTTP Headers:\n";
$responseHeaders = $response->getHeaders();
foreach ($responseHeaders as $responseHeaderName => $responseHeaderValue) {
echo "$responseHeaderName: $responseHeaderValue\n";
}
}
} catch (Zend_Http_Client_Exception $e) {
echo '<p>An error occurred (' .$e->getMessage(). ')</p>';
}
?>