ehttpclient Http Client Extension for Yii

  1. Requirements
  2. TODO
  3. Usage
  4. ChangeLog
  5. Resources

I wanted to have a proper Http Client for my Yii Applications. Even though there are a couple of good classes around, I wanted a good one to extend from and also that has an already proven efficiency. So I got into Zend Http Client library (I really do not like to reinvent the wheel -do not worry Zend guys, I have already included the license in it). Hope Yii comes in near future with an HTTP Client by its own, I think is a great thing to have to develop greater things (mash-up applications, social network connectors, universal password validations, Xml-Rpc Servers-Clients, and so on...)

I have worked through the classes and checked that all that is required is within the package. So, with this library you do not need to worry about the inclusion of the Zend Library on the vendors folder.

This version is beta and even though I have tested most of its functionality, I would love your feedback and tests to improve it and make it worth to in have our must have libraries.

I have created a GitHub repository for those willing to contribute on any of the extensions I created. Please, check the link at the bottom of this wiki.


Working from Yii v1.1.5 till v1.1.9


Add streaming support


Unpack compressed files and place them on your protected/extensions directory.

You can refer to the Zend_Http_Client documentation (remember to exchange the names from Zend to those in the extension).

Here two easy samples (Send me your tests, I would love to see more in action)

Example 1 - Getting my twitter statuses


// get my twitter status
$client = new EHttpClient('', array(
    'maxredirects' => 0,
    'timeout'      => 30));

$response = $client->request();

    echo '<pre>' . htmlentities($response->getBody()) .'</pre>';
    echo $response->getRawBody();

Example 2 - Performing a Full Page Google Search Now, using EHttpClientAdapterCurl


$client = new EHttpClient('', array(
    'maxredirects' => 3,
    'timeout'      => 30,
    'adapter'	   => 'EHttpClientAdapterCurl'));

$client->setParameterGet(array('hl'=>'es', 'q'=>'manolo'));

$response = $client->request();

   echo $response->getBody();

Example 3 - Downloading using stream


$uri = EUri::factory('');

$temp_dir = realpath(sys_get_temp_dir()). DIRECTORY_SEPARATOR;

$temp_file = tempnam($temp_dir, 'TEST');

$config = array('adapter'=>'EHttpClientAdapterCurl', 'timeout'=>'60');

$client = new EHttpClient($uri, $config);

$response = $client->request('GET');

   // copy stream to temporary file... 
   copy( $response->getStreamName(), $temp_dir . $temp_file );
   // other work with temporary file (ie decompress, decrypt, etc...)


14 0
5 600 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Web Service
Developed by: Antonio Ramirez
Created on: Dec 27, 2010
Last updated: 12 years ago


show all

Related Extensions