I connect to api, the data is received back, but with an error: curl_setopt () expects exactly 3 parameters, 2 given

$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://myurl.com/get/data'); curl_setopt($ch, CURLINFO_HEADER_OUT, true); curl_setopt($ch, CURLOPT_ENCODING); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'API_KEY: '.$api_opts, 'Content-Type: application/json', 'Accept: application/json', )); $err = curl_errno($ch); $result = json_encode(curl_exec($ch)); curl_close($ch); return $result; 

What is it?

    1 answer 1

    The error is exactly what the problem is - curl_setopt should take three arguments, and in the line

     curl_setopt($ch, CURLOPT_ENCODING); 

    there are only two of them. It is necessary to transfer the third parameter - the coding, for example

     curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate'); 

    http://php.net/manual/ru/function.curl-setopt.php