Exemplo n.º 1
0
 /**
  * Create a new XML cURL API call instance
  *
  * @param string $url       URL to send the request to
  * @param array  $curl_opts Array of additional cURL options to set
  * @param array  $headers   Array of headers to set in addition to defaults
  */
 public function __construct($url = null, array $curl_opts = array(), array $headers = array())
 {
     parent::__construct($this::VERSION, $this::ENCODING, $this::ROOT_EL, $this::XMLNS);
     $this->curlInit($url);
     $this->headers['Accept'] = join(',', $this->accept);
     $headers = array_merge($this->headers, $headers);
     $this->curlSetOptArray($this->default_opts);
     $this->curlSetOpt(CURLOPT_HTTPHEADER, array_map(function ($key, $value) {
         return "{$key}: {$value}";
     }, array_keys($headers), array_values($headers)));
     $this->curlSetOptArray($curl_opts);
 }
Exemplo n.º 2
0
 /**
  * Builds the XML document and returns it as a string
  *
  * @return string XML Document as string
  * @example exit($this)
  */
 public function __toString()
 {
     try {
         $this->root->setAttributeNS(self::XMLNS, self::MOZ_NS, self::MOZ_XMLNS);
         $this->ShortName($this->name)->searchTitle($this->name)->Description($this->description)->Url([$this->URL, '@type' => 'text/html', '@method' => $this->method, '@template' => "{$this->URL}/{$this->template}"])->pluginURL("{$this->URL}/tags/{searchTerms}")->Image([$this->image, '@height' => $this->image_y, '@width' => $this->image_x])->{'moz:SearchForm'}($this->URL)->{'moz:UpdateUrl'}($this->URLToString())->{'moz:IconUpdateUrl'}($this->image)->{'moz:UpdateInterval'}($this->UpdateInterval)->Url(['@type' => self::CONTENT_TYPE, '@rel' => 'self', '@template' => $this->URLToString()]);
         if (is_string($this->suggestions_URL) and $this->isURL($this->suggestions_URL)) {
             $this->Url(['@type' => self::SUGGESTIONS_TYPE, '@template' => $this->suggestions_URL]);
         }
     } catch (\DOMException $e) {
         $this->ExceptionAsXML($e, $this->root);
     }
     return parent::__toString();
 }