Sign in and see if your page is online with curl

0

I want to log in to different pages with Curl and see if everything is OK.  Example: login successfully returns a text to the screen "login ok" if it did not work take some element of the error page and me printa in the screen under the "login error" panel (I will use to test proxys and create chat bots more front). As an example I tried to make a simple code on Facebook, below:

<?php

$login_email = '[email protected]';
$login_pass = 'minhasenha';


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://m.facebook.com/login.php');
curl_setopt($ch, CURLOPT_POSTFIELDS,'charset_test=€,´,€,´,水,Д,Є&email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&login=Login');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$fbMain = curl_exec($ch)
?>

The problem is that after this simple login system I do not know how to print down the status that tells me whether the login was successfully done or not, example of what I want to do more with Proxy Tester list:

192.173.0.1 Live
192.168.0.2 die
192.168.0.4 Live
    
asked by anonymous 13.06.2017 / 21:08

1 answer

1

The curl_exec function returns the request's HTML, and you can also get the http code with the curl_getinfo function.

$document = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

With the return of HTML to identify certain strings that identify whether it was logged in or not. I usually use a strpos in these cases.

In your case, you can give echo $fbMain; and see what it returns.

    
13.06.2017 / 23:24