I'm trying to make an automatic login system for my drugstore, where I access a portal and with my clients' CPF, they have a discount on some medicines.
I'm already wrapped up in the login part, via cURL. Here is the code:
<?php
$cookie="cookie.txt";
$login_url = "https://www.portaldadrogaria.com.br/11v1/";
$target_url = "https://www.portaldadrogaria.com.br/11v1/Inicio";
$useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$field['cnpj'] = 'xxxxxxxxx';
$field['hd_height'] = '768';
$field['hd_ip'] = '';
$field['hd_width'] = '1024';
$field['password'] = 'xxxxxx';
$field['username'] = 'xxxxxxx';
$datafield = http_build_query($field);
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_URL, $login_url);
curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datafield);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, $target_url);
$ket_qua = curl_exec($ch);
echo $ket_qua;
curl_close($ch);
?>
Can anyone help me? I'm new to cURL! Thanks!