Accent error when using cURL

0
Good afternoon, how are you?

I am trying to pull some information via cURL from the post office, however it is returning me but with accent error, would I have some way to change the header that is coming from it to correct this problem of accents?

I'm pulling this way:

<?php

$codigoRastreio = urlencode($_GET['cod']);
$post = array('Objetos' => $codigoRastreio);
// iniciar CURL
$ch = curl_init();
// informar URL e outras funções ao CURL
curl_setopt($ch, CURLOPT_URL, "http://www2.correios.com.br/sistemas/rastreamento/resultado_semcontent.cfm");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($post));
// Acessar a URL e retornar a saída
$output = curl_exec($ch);
// liberar
curl_close($ch);
// Imprimir a saída
echo $output;

?>
    
asked by anonymous 18.01.2018 / 19:05

1 answer

0

I've been able to fix it, here is the updated code:

$codigoRastreio = urlencode($_GET['cod']);
$post = array('Objetos' => $codigoRastreio);
// iniciar CURL
$ch = curl_init();
// informar URL e outras funções ao CURL
curl_setopt($ch, CURLOPT_URL, "http://www2.correios.com.br/sistemas/rastreamento/resultado_semcontent.cfm");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($post));
// Acessar a URL e retornar a saída
$output = curl_exec($ch);
// liberar
curl_close($ch);
// Imprimir a saída
echo utf8_encode($output);
    
18.01.2018 / 20:08