Table of Contents
Zend_HttpClient
provides an easy interface with which to perform HTTP requests.
Zend_HttpClient
is able to perform GET, POST, PUT and DELETE requests.
![]() |
Note |
---|---|
Zend_HttpClient follows up to 5 HTTP redirections by default. To change this behavior, pass the
maximum number of allowed redirections to the get() method.
|
Example 6.1. Performing a Basic GET Request
<?php require_once 'Zend/HttpClient.php'; try { $http = new Zend_HttpClient('http://example.org'); $response = $http->get(); if ($response->isSuccessful()) { echo $response->getBody(); } else { echo '<p>An error occurred</p>'; } } catch (Zend_HttpClient_Exception $e) { echo '<p>An error occurred (' .$e->getMessage(). ')</p>'; } ?>