I'm trying to create a theft to automate a process, as post here: Automate process - Robot?
Given the suggestions, I'm following using cURL. What is happening is the following: It manages to login, goes to the second page where the form is that I want the POST to be done but it does not return anything to me. My question is if I have to use some command that saves the login session. Because of what I'm seeing it is returning a link that displays User and invalid password or Invalid Session in the second POST. Here is my code:
// Inicia o cURL
$ch = curl_init();
// Define a URL original (do formulário de login)
curl_setopt($ch, CURLOPT_URL, 'http://site.com/consulta/index.php');
// Habilita o protocolo POST
curl_setopt ($ch, CURLOPT_POST, 1);
// Define os parâmetros que serão enviados
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'usuario=teste&senha=teste');
// Imita o comportamento patrão dos navegadores: manipular cookies
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
// Define o tipo de transferência (Padrão: 1)
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// Executa a requisição
$store = curl_exec ($ch);
// Define uma nova URL para ser chamada (após o login)
curl_setopt($ch, CURLOPT_URL, 'http://site.com/consulta/forms.php');
// Habilita o protocolo POST
curl_setopt ($ch, CURLOPT_POST, 1);
// Define os parâmetros que serão enviados
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'campoNome=Joao');
// Executa a segunda requisição
$content = curl_exec ($ch);
//show information regarding the request
print_r(curl_getinfo($ch));
echo curl_errno($ch) . '-' .
curl_error($ch);
// Encerra o cURL
curl_close ($ch);
If I put an echo of the $ content exits the form page, but without any information or typed fields ..