Representation of a response from Twitter.

Provides:

  • method for testing if we have a successful call
  • method for retrieving errors, if any
  • method for retrieving the raw JSON
  • method for retrieving the decoded response
  • proxying to elements of the decoded response via property overloading
category Zend
package Zend_Service
subpackage Twitter
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Constructor

__construct(\Zend_Http_Response $httpResponse) 

Assigns the HTTP response to a property, as well as the body representation. It then attempts to decode the body as JSON.

Parameters

$httpResponse

\Zend_Http_Response

Exceptions

\Zend_Service_Twitter_Exception if unable to decode JSON response

Property overloading to JSON elements

__get(string $name) : mixed

If a named property exists within the JSON response returned, proxies to it. Otherwise, returns null.

Parameters

$name

string

Returns

mixed

Retrieve the errors.

getErrors() : array

Twitter should return a standard error object, which contains an "errors" property pointing to an array of errors. This method will return that array if present, and raise an exception if not detected.

If the response was successful, an empty array is returned.

Exceptions

\Exception\DomainException if unable to detect structure of error response

Returns

array

Retrieve the raw response body

getRawResponse() : string

Returns

string

Did an error occur in the request?

isError() : boolean

Returns

boolean

Was the request successful?

isSuccess() : boolean

Returns

boolean

Retun the decoded response body

toValue() : array | \stdClass

Returns

array\stdClass

 Properties

 

$httpResponse

$httpResponse : \Zend_Http_Response

Default

 

$jsonBody

$jsonBody : array | \stdClass

Default

 

$rawBody

$rawBody : string

Default