Curl does not return HTML

Asked

Viewed 495 times

0

I am creating a custom management panel, but I’m having difficulties, because the HTML of my request after the login does not come to me on the screen, in place of it is displayed again the screen login. How can I do the login and show off the bird /account after the login?

<?php

$email = '    ';

$senha = '   ';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://minhaconta.payleven.com.br/login_check');

curl_setopt($ch, CURLOPT_COOKIESESSION, true);

curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');

curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");

curl_setopt ($ch, CURLOPT_POST, 1);

curl_setopt ($ch, CURLOPT_POSTFIELDS, '_username=' . urlencode($email) . '&_password=' . urlencode($senha)); 

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_URL, 'http://minhaconta.payleven.com.br/account');

$track = curl_exec ($ch);

curl_close ($ch);

echo $track;

?>

Answer:

HTTP/1.1 301 Moved Permanently Content-Type: text/html Date: Sun, 09 Jul 2017 18:15:09 GMT Location: https://minhaconta.payleven.com.br/account Server: nginx Content-Length: 178 Connection: keep-alive HTTP/1.1 302 Found Cache-Control: no-cache Content-Type: text/html; charset=UTF-8 Date: Sun, 09 Jul 2017 18:15:07 GMT Location: https://minhaconta.payleven.com.br/login Server: nginx Set-Cookie: village=218gi74f0dgc7osgtmts2jbns4; path=/ Content-Length: 5183 Connection: keep-alive HTTP/1.1 200 OK Cache-Control: no-cache Content-Type: text/html; charset=UTF-8 Date: Sun, 09 Jul 2017 18:15:09 GMT Server: nginx Vary: Accept-Encoding Content-Length: 11320 Connection: keep-alive
  • Add that curl_setopt($ch, CURLOPT_HEADER, 1); and put the result in the question. (*Hide sensitive data if it exists). Also activate the php error display.

  • I edited the question with the result

  • In CURLOPT_URL, define how https://minhaconta.payleven.com.br/login.

  • When I place I returned the error: error 405 Method Not Allowed

  • Ah.. The right thing is /login_check same. Remove the bottom /account. Just switch to https. Example: curl_setopt($ch, CURLOPT_URL, 'https://minhaconta.payleven.com.br/login_check');

  • Obviously, you will have to set the SSL parameters CURLOPT_SSL_VERIFYHOST, CURLOPT_SSL_VERIFYHOST, CURLOPT_SSLVERSION, CURLOPT_CAINFO

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.