I'm trying to get the deadline dynamically using the Post Office WebService, so I'm using this documentation .
If you enter the test page , you can enter the CAP, for example, 4510
and the source and destination ceps to get the return on an XML page.
I've found that this form does a simple POST by copying it to my localhost. But when I try to do it without the form, but using curl
I did not succeed.
My code so far is:
$data['nCdServico'] = '4510';
$data['sCepOrigem'] = '36572008';
$data['sCepDestino'] = '36700000';
$url = 'http://ws.correios.com.br/calculador/CalcPrecoPrazo.asmx/CalcPrazo';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$resp = curl_exec($ch);
curl_close($ch);
var_dump($resp);exit;
But the return is false
I would like some help to know what I'm forgetting so that the return is the data of the submission deadline and not just the boolean false.