/** * Initializes Amazon data into $datas array */ public function __construct() { //This is the XML document string //We loop through the XML string starting at child node Items -> Item $this->_datas = parent::_getArrayData()->Items->Item; }
/** * Main request to grab Amazon data in xml format. This is where the api gets called. * @return xml array */ protected function _getArrayData() { if (self::$_counter == 0) { //Only run curl on first iteration, until data has been purged $curl = curl_init($this->_authenticatedUrl); //Initialize the url $this->_curlOptions($curl, $this->_method); //Set the options, also set GET command self::$_arrayData = simplexml_load_string(curl_exec($curl)); //Executes rest command via curl, and converts json output into php array } self::$_counter = 1; return self::$_arrayData; }