It would be better if you showed the part of the code that is giving error. But common errors when using CURL is the fact that it is not installed on the server, the way the data is treated and the SSL configuration. You can try the following:
Make sure it’s installed:
function _isCurl() {
return function_exists('curl_version');
}
When setting the parameters put 0 (zero) to SSL:
$ch = curl_init("URL_PARA_CONECTAR");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
...
Treat the result as a json array:
...
$data = curl_exec($ch);
$response = json_decode($data, true); // o true indica que você quer o resultado como array
An example of configuration would be:
$valoresParaSubmeter = array('key1' => 'valor1', 'key2' => 'valor2');
$ch = curl_init("URL_PARA_CONECTAR");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $valoresParaSubmeter);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$data = curl_exec($ch);
$response = json_decode($data, true); // o true indica que você quer o resultado como array
var_dump($response);
I hope I’ve helped. :)
Put the code so we know if it’s a problem with him.
– Guilherme Nascimento