Download this library
https://github.com/php-curl-class/php-curl-class
It may need some changes so you can download this working lib
https://drive.google.com/file/d/0Bw4oKsVETs62ZEdTNzJqcV9OVnM/view?usp=sharing
version with appropriate changes made by me and check below example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function curlOnetLogin(){ | |
$url = 'https://konto.onet.pl/login.html?app_id=poczta.onet.pl.front'; | |
$login = 'YOUR_LOGIN@onet.pl'; | |
$password = 'YOUR_PASSWORD'; | |
$f = fopen('onet_request.txt', 'a+'); | |
fwrite($f, "\n==========\n[".date("Y-m-d H:i:s", time())."]\n"); | |
// open login page and save cookies | |
$curl = new curl(); | |
$cookieName = dirname(__FILE__).'/onetCookie.txt'; | |
$curl -> setCookieFile($cookieName); | |
$curl -> setOpt(CURLOPT_COOKIEFILE, $cookieName); | |
$curl -> setOpt(CURLOPT_STDERR, $f); | |
$curl -> setOpt(CURLOPT_VERBOSE, true); | |
$curl -> setOpt(CURLOPT_SSL_VERIFYPEER, false); | |
$curl -> setOpt(CURLOPT_SSL_VERIFYHOST, false); | |
$curl -> setOpt(CURLOPT_FOLLOWLOCATION, true); | |
$curl -> setOpt(CURLOPT_RETURNTRANSFER, true); | |
$curl -> setOpt(CURLOPT_TIMEOUT, 30); | |
$curl -> setOpt(CURLOPT_URL, $url); | |
$pageContent = $curl -> exec(); | |
while($curl -> response_headers['Location']){ | |
$curl -> setOpt(CURLOPT_URL, $curl -> response_headers['Location']); | |
$curl -> exec(); | |
} | |
// perform login | |
$curl -> setOpt(CURLOPT_POST, true); | |
$curl -> setOpt(CURLOPT_URL, $url); | |
$curl -> setOpt(CURLOPT_POSTFIELDS, http_build_query( array( | |
'noscript' => true, | |
'login' => $login, | |
'password' => $password, | |
'perm' => 0, | |
'perm' => 1, | |
'provider' => "", | |
'access_token' => "", | |
'referrer' => "", | |
'cookie' => 'onet_ubi, onetzuo_ticket, onet_cid, __gfp_64b, onet_cinf, onet_sid, __utma, __utmc, __utmz, __utma, __utmc, __utmz, onet_uoi, onet_crt_adtech', | |
'script' => 226, | |
'adblock' => 1 | |
), '', '&')); | |
$pageContent = $curl -> exec(); | |
fclose($f); | |
return $pageContent; | |
} |
No comments:
Post a Comment