예제 #1
0
파일: Base.php 프로젝트: Lord-Simon/IRC-Bot
 /**
  * Fetches data from $uri
  *
  * @param string $uri
  * @return string
  */
 protected function fetch($uri)
 {
     $this->bot->log("Fetching from URI: " . $uri);
     // create curl resource
     $ch = curl_init();
     // set url
     curl_setopt($ch, CURLOPT_URL, $uri);
     //return the transfer as a string
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
     // $output contains the output string
     $output = curl_exec($ch);
     // close curl resource to free up system resources
     curl_close($ch);
     $this->bot->log("Data fetched: " . $output);
     return $output;
 }
예제 #2
0
 /**
  * Fetches data from $uri
  *
  * @param string $uri
  * @return string
  */
 protected function fetch($uri)
 {
     $this->bot->log("Fetching from URI: " . $uri);
     // create curl resource
     $ch = curl_init();
     // set url
     curl_setopt($ch, CURLOPT_URL, $uri);
     // Set a user agent. Some sites require it (e.g. GitHub API).
     curl_setopt($ch, CURLOPT_USERAGENT, 'WildPHP/IRCBot');
     //return the transfer as a string
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
     // $output contains the output string
     $output = curl_exec($ch);
     // close curl resource to free up system resources
     curl_close($ch);
     $this->bot->log("Data fetched: " . $output);
     return $output;
 }