Use curl correctly for targeting via post

0

Colleagues.

I tried everything, I used my code and searched the internet, but I do not know what else to do. I need to make the system user, when accessing a certain link, open another site already logged in. Via POST via CURL. My last code follows below and is returning code 200. When I use the username and password below directly by the site, it can log in, but when I try for our system, it gives this error that I reported:

$params = array(
        'usuario' => 'teste.usuario',
        'senha' => '123456'
);
$camposStrings = '';
 foreach($params as $key=>$valores){
    $camposStrings .= $key.'='.$valores.'&';    
}
$camposStrings .= rtrim($camposStrings, '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.siteparceiro.com.br/");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, count($camposStrings));
curl_setopt($ch, CURLOPT_POSTFIELDS, $camposStrings);
$output=curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo $status;
curl_close($ch);
    
asked by anonymous 18.05.2016 / 02:26

0 answers