Rest/Client.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Rest
- Subpackage
- Client
- Version
- $Id: Client.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Rest_Client
- Parent(s)
- \Zend_Service_Abstract
- Children
- \Zend_Service_Twitter_Search
- \Zend_Service_Twitter
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties


\Zend_Http_Client $_httpClient = null
HTTP Client used to query all web services
Inherited from: \Zend_Service_Abstract::$$_httpClientnull
Details- Type
- \Zend_Http_Client
- Inherited_from
- \Zend_Service_Abstract::$$_httpClient


bool $_noReset = false
Flag indicating the Zend_Http_Client is fresh and needs no reset.
<p>true if you do not want a reset. Default false.</p>Must be set explicitly if you want to keep preset parameters.
false
Details- Type
- bool


\Zend_Uri_Http $_uri = null
Zend_Uri of this web service
null
Details- Type
- \Zend_Uri_Http
Methods


__call(string $method, array $args) : \Zend_Rest_Client_Result | \Zend_Rest_Client
Method call overload
Allows calling REST actions as object methods; however, you must follow-up by chaining the request with a request to an HTTP request method (post, get, delete, put):
$response = $rest->sayHello('Foo', 'Manchu')->get();
Or use them together, but in sequential calls:
$rest->sayHello('Foo', 'Manchu');
$response = $rest->get();
Name | Type | Description |
---|---|---|
$method | string | Method name |
$args | array | Method args |
Type | Description |
---|---|
\Zend_Rest_Client_Result | \Zend_Rest_Client | Zend_Rest_Client if using a remote method, Zend_Rest_Client_Result if using an HTTP request method |


__construct(string | \Zend_Uri_Http $uri = null) : void
Constructor
Name | Type | Description |
---|---|---|
$uri | string | \Zend_Uri_Http | URI for the web service |


_performPost(mixed $method, mixed $data = null) : \Zend_Http_Response
Perform a POST or PUT
Performs a POST or PUT request. Any data provided is set in the HTTP client. String data is pushed in as raw POST data; array or object data is pushed in as POST parameters.
Name | Type | Description |
---|---|---|
$method | mixed | |
$data | mixed |
Type | Description |
---|---|
\Zend_Http_Response |


_prepareRest(string $path) : void
Call a remote REST web service URI and return the Zend_Http_Response object
Name | Type | Description |
---|---|---|
$path | string | The path to append to the URI |
Exception | Description |
---|---|
\Zend_Rest_Client_Exception |


getHttpClient() : \Zend_Http_Client
Gets the HTTP client object.
Inherited from: \Zend_Service_Abstract::getHttpClient()Type | Description |
---|---|
\Zend_Http_Client |


getUri() : \Zend_Uri_Http
Retrieve the current request URI object
Type | Description |
---|---|
\Zend_Uri_Http |


restDelete(string $path, $data = null) : \Zend_Http_Response
Performs an HTTP DELETE request to $path.
Name | Type | Description |
---|---|---|
$path | string | |
$data |
Type | Description |
---|---|
\Zend_Http_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception |


restGet(string $path, array $query = null) : \Zend_Http_Response
Performs an HTTP GET request to the $path.
Name | Type | Description |
---|---|---|
$path | string | |
$query | array | Array of GET parameters |
Type | Description |
---|---|
\Zend_Http_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception |


restPost(string $path, mixed $data = null) : \Zend_Http_Response
Performs an HTTP POST request to $path.
Name | Type | Description |
---|---|---|
$path | string | |
$data | mixed | Raw data to send |
Type | Description |
---|---|
\Zend_Http_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception |


restPut(string $path, mixed $data = null) : \Zend_Http_Response
Performs an HTTP PUT request to $path.
Name | Type | Description |
---|---|---|
$path | string | |
$data | mixed | Raw data to send in request |
Type | Description |
---|---|
\Zend_Http_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception |


setHttpClient(\Zend_Http_Client $httpClient) : void
Sets the HTTP client object to use for retrieving the feeds.
Inherited from: \Zend_Service_Abstract::setHttpClient()If none is set, the default Zend_Http_Client will be used.
Name | Type | Description |
---|---|---|
$httpClient | \Zend_Http_Client |


setNoReset(boolean $bool = true) : void
Tells Zend_Rest_Client not to reset all parameters on it's Zend_Http_Client.
If you want no reset, this must be called explicitly before every request for which you do not want to reset the parameters. Parameters will accumulate between requests, but as soon as you do not call this function prior to any request, all preset parameters will be reset as by default.
Name | Type | Description |
---|---|---|
$bool | boolean |


setUri(string | \Zend_Uri_Http $uri) : \Zend_Rest_Client
Set the URI to use in the request
Name | Type | Description |
---|---|---|
$uri | string | \Zend_Uri_Http | URI for the web service |
Type | Description |
---|---|
\Zend_Rest_Client |