Source for file Response.php
Documentation is available at Response.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* Services_Yahoo_JP Auction Response
* LICENSE: This source file is subject to the New BSD license that is
* available through the world-wide-web at the following URI:
* http://www.opensource.org/licenses/bsd-license.php. If you did not receive
* a copy of the New BSD License and are unable to obtain it through the web,
* please send a note to license@php.net so we can mail you a copy immediately.
* @package Services_Yahoo_JP
* @author Tetsuya Nakase <phpizer@gmail.com>
* @copyright 2008 Tetsuya Nakase
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: Response.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $
* @link http://phpize.net
* Services_Yahoo Auction Response class
* This class provides methods for accessing the response of a Auction
* @package Services_Yahoo_JP
* @author Tetsuya Nakase <phpizer@gmail.com>
* @copyright 2008 Tetsuya Nakase
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version Release: 0.0.1
* @link http://phpize.net
private $_isValidIterator = true;
private $_iteratorCounter = 0;
private $_results = array ();
* @param object $request HTTP_Request Instance of
* HTTP_Request that was used for the request
* @throws Services_Yahoo_Exception
$this->_request = $request;
if ($this->_isError () == true ) {
$exception = new Services_Yahoo_Exception ("Auction query failed");
$exception->addErrors ($this->_getMessages ());
* Get number of result sets returned by the content analysis
* @return integer Number of result sets returned
return count((array) $this->xml->{$this->_indexkey});
* Get the HTTP_Request instance that was used for the query
* Access to the HTTP_Request instance is useful for introspecting
* into the request details. (E.g. for getting the HTTP response
* @return object HTTP_Request Instance of HTTP_Request
// {{{ Iterator implementation
* get current result of response
* @return array current result of response
return (array) $this->xml->{$this->_indexkey}[$this->_iteratorCounter];
* get next result of response
* @return array next result of response
$this->_iteratorCounter++;
if (!isset ($this->xml->{$this->_indexkey}[$this->_iteratorCounter])) {
$this->_isValidIterator = false;
* get counter for iterator
return $this->_iteratorCounter;
* clear counter for iterator
$this->_iteratorCounter = 0;
* @return bool validate status
return $this->_isValidIterator;
* Parse XML from the response
* @throws Services_Yahoo_Exception
private function _parseRequest ()
if ($this->xml === false ) {
Services_Yahoo_Exception ("The response contained no valid XML");
* Determine if an error was returned by the Yahoo API
* This method evaluates the HTTP response code. If it indicates
* an error, the method returns true.
* @return boolean True on error, otherwise false.
private function _isError ()
return in_array($this->_request->getResponseCode (),
array (400 , 403 , 404 , 503 ));
* Get all error messages if the response contained an error
* Returns all errors in an numerically indexed array that were
private function _getMessages ()
foreach ($this->xml->Message as $message) {
$returnValue[] = $message;
* Set Key for Response Loop Field
* @param string $key key for loop in result
return $this->_indexkey = $key;
* @param string $name key in result
* @return string value of attribute
if (isset ($this->xml[$name])) {
return $this->xml[$name];
Documentation generated on Fri, 19 Sep 2008 21:30:07 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|