/** * Returns array of all publisher names * * @access public * @return array all publisher names */ function getPublishers() { $xml = $this->helper->doHttpGet(Services_Gnip_Publisher::getIndexUrl()); $xml = new SimpleXMLElement($xml); $publishers = array(); foreach ($xml->children() as $child) { $publishers[] = Services_Gnip_Publisher::fromXML($child); } return $publishers; }
/** * Create new Gnip Publisher -- with XML value -- then validate against returned string value. * * @access public * @param void * @return void */ function testFromXml() { $publisher = Services_Gnip_Publisher::fromXML(new SimpleXMLElement("<publisher name='bob'/>")); $this->assertEquals("bob", $publisher->name); }
/** * Retrieves all publishers from the Gnip servers. * * @param string $scope publisher scope (my or gnip) default is gnip * @return array containing Services_Gnip_Publisher objects */ function getAllPublishers($scope = "gnip") { $scope = $this->_scopeprep($scope); try { $xml = $this->helper->doHttpGet($scope . Services_Gnip_Publisher::getIndexUrl()); $xml = new SimpleXMLElement($xml); $publishers = array(); foreach ($xml->children() as $child) { $publishers[] = Services_Gnip_Publisher::fromXML($child->asXML()); } return $publishers; } catch (Exception $e) { $message = "There was a problem when calling getAllPublishers(). Status message: "; $this->_handleDebug($message, $this->debug, $e); } }
function testFromXml() { $publisher = Services_Gnip_Publisher::fromXML("<publisher name='bob'><supportedRuleTypes><type>actor</type></supportedRuleTypes></publisher>"); $this->assertEquals("bob", $publisher->name); $this->assertEquals("actor", $publisher->supported_rule_types[0]->type); }