Exemple #1
0
 public function testShouldCallAllMethods()
 {
     $resource = $this->sut->init();
     $this->sut->setOpt($resource, CURLOPT_POST, 0);
     $this->sut->exec($resource);
     $this->sut->errno($resource);
     $this->sut->error($resource);
     $this->sut->close($resource);
 }
Exemple #2
0
 /**
  * @param $url
  * @return string
  * @throws \Exception
  */
 public function request($url)
 {
     $ch = $this->libCurl->init();
     $this->libCurl->setOpt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     $this->libCurl->setOpt($ch, CURLOPT_URL, $url);
     $this->libCurl->setOpt($ch, CURLOPT_RETURNTRANSFER, 1);
     $this->libCurl->setOpt($ch, CURLOPT_TIMEOUT, 10);
     $data = $this->libCurl->exec($ch);
     if ($this->libCurl->errno($ch)) {
         throw new \Exception($this->libCurl->error($ch), $this->libCurl->errno($ch));
     } else {
         $this->libCurl->close($ch);
         return $data;
     }
 }