I'm having trouble placing a POST request on a site through the Guzzle component. The target site is: link
He even enters the site but no results appear. I do not know if the problem is in HOW I make the request or if it is the PARAMETERS that I pass.
Someone could tell you what's wrong
Code:
<?php
use GuzzleHttp\Client;
$client = new Client();
//Padrão para as requisições
$headers = [
'headers' =>
[
'User-Agent' => 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36',
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language' => 'pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4',
'Accept-Encoding' => 'gzip, deflate',
'Referer' => 'http://ciagri.iea.sp.gov.br/nia1/subjetiva.aspx?cod_sis=1&idioma=1',
'Origin' => 'http://ciagri.iea.sp.gov.br',
'Host' => 'ciagri.iea.sp.gov.br',
'Connection' => 'keep-alive'
]
];
//Parâmetros para a primeira requisição
$body = [
'body' =>
[
'cmbAno_Inicial' => '1983',
'cmbAno_Final'=>'2014',
'cmbRegiao'=>'EDR',
'chkRegiao$0'=>'on',
'chkPerg$69'=>'on',
'imgPesquisar.x'=>'67',
'imgPesquisar.y'=>'20',
'cmbTpSaida'=>'RA'
]
];
//Primeira requisição, passamos a consulta
$param = array_merge($body, $headers);
$request = $client->createRequest('POST', 'http://ciagri.iea.sp.gov.br/nia1/subjetiva.aspx?cod_sis=1&idioma=1', $param);
$retorno=$client->send($request);
$corpo=$retorno->getBody();
echo $corpo;