curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER argument
<p>My code:</p>

<pre><code>private static $API_ACCESS_KEY = 'AIzaSyDG3fYAj1uW7VB-wejaMJyJXiO5JagAsYI';
$headers = array(
            'Authorization: key=' .self::$API_ACCESS_KEY,
            'Content-Type: application/json');

private function useCurl(&amp;$model, $url, $headers, $fields = null) {
            // Open connection
                $ch = curl_init();
            if ($url) {
                // Set the url, number of POST vars, POST data
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            // Disabling SSL Certificate support temporarly
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            if ($fields) {
                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
            }

            // Execute post
            $result = curl_exec($ch);
            if ($result === FALSE) {
                die('Curl failed: ' . curl_error($ch));
            }

            // Close connection
            curl_close($ch);

            return $result;
    }
}
</code></pre>

<p>Error:</p>

<blockquote>
  <p>curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER argument</p>
</blockquote>