Snippets > cURL Helper Class


#php

$result = CurlHelper::sendRequest([
    CURLOPT_URL             => 'http://example.com',
    CURLOPT_RETURNTRANSFER  => true
]);

print_r($result);

class CurlHelper
{
    public static function sendRequest($options)
    {
        $ch = curl_init();
        curl_setopt_array($ch, $options);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
}