Cmfcmf\OpenWeatherMap\Fetcher\CurlFetcher::fetch PHP Method

fetch() public method

public fetch ( $url )
    public function fetch($url)
    {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt_array($ch, $this->curlOptions);
        $content = curl_exec($ch);
        curl_close($ch);
        return $content;
    }

Usage Example

 public function testValidUrl()
 {
     $fetcher = new CurlFetcher();
     $content = $fetcher->fetch('http://httpbin.org/html');
     $this->assertContains('Herman Melville', $content);
 }