Beispiel #1
0
 /**
  * @param $feedUrl
  */
 public function saveFeed($feedUrl)
 {
     $curl = new \anlutro\cURL\cURL();
     $request = $curl->newRequest('get', $feedUrl)->setOption(CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0');
     $response = $request->send();
     file_put_contents($this->feedUrl, $response->body);
 }
 private function curl()
 {
     $curl = new \anlutro\cURL\cURL();
     switch (true) {
         case preg_match('/post/i', $this->getRequest()):
             return $curl->newRequest('post', $this->getUrl(), ['payload' => json_encode(json_decode($this->getData(), true))])->setHeaders($this->getHeaders())->send()->body;
         case preg_match('/get/i', $this->getRequest()):
             return $curl->newRequest('get', $this->getUrl(), [])->setHeaders($this->getHeaders())->send()->body;
         default:
             return $curl->newRequest($this->getRequest(), $this->getUrl(), [])->setHeaders($this->getHeaders())->send()->body;
     }
 }