Beispiel #1
0
 /**
  * Converts XML formatted filter to Services_Gnip_Filter object.
  * 
  * @param string $xml XML data
  * @return object Services_Gnip_Filter
  */
 public function fromXML($xml)
 {
     $xml_element = new SimpleXMLElement($xml);
     $f = new Services_Gnip_Filter($xml_element["name"], $xml_element["fullData"]);
     $f->postURL = strval($xml_element->postURL);
     foreach ($xml_element->rule as $rule_node) {
         $f->rules[] = Services_Gnip_Rule::fromXML($rule_node->asXML());
     }
     return $f;
 }
 /**
  * Gets a rule given an existing valid publisher/filter combination. Used
  * mostly for verification that the rule does exist.
  * 
  * @param string $publisherName name of the publisher that contains the filter
  * @param string $filterName name of filter that contains rules
  * @param object $rule Service_Gnip_Rule object
  * @param string $scope publisher scope (my or gnip) default is gnip
  * @return Service_Gnip_Rule object
  */
 function getRule($publisherName, $filterName, $rule, $scope = "gnip")
 {
     $scope = $this->_scopeprep($scope);
     try {
         $xml = $this->helper->doHttpGet($scope . $rule->getUrl($publisherName, $filterName) . "?type={$rule->type}&value={$rule->value}");
         return Services_Gnip_Rule::fromXML($xml);
     } catch (Exception $e) {
         $message = "There was a problem when calling getRule on publisher {$publisherName} and filter {$filterName} with rule type {$rule->type} and value {$rule->value}. Status message: ";
         $this->_handleDebug($message, $this->debug, $e);
     }
 }
Beispiel #3
0
 /**
  * Instantiates Services_Gnip_Filter with current class data values
  *
  * @access    public
  * @param     XMLElement               $xml      XML Filter
  * @return    Services_Gnip_Filter               Services_Gnip_Filter object
  */
 public static function fromXML(SimpleXMLElement $xml)
 {
     $f = new Services_Gnip_Filter($xml["name"], $xml["fullData"]);
     $f->postUrl = strval($xml->postUrl);
     $f->jid = strval($xml->jid);
     foreach ($xml->rule as $rule_node) {
         $f->rules[] = Services_Gnip_Rule::fromXML($rule_node);
     }
     return $f;
 }