N
N
Ninok7772015-11-12 12:30:12
PHP
Ninok777, 2015-11-12 12:30:12

How to log in to mamba.ru via cURL+PHP?

Hello. Help finish the script. The script must be authorized in mamba via cURL
<?php
set_time_limit(0);
$login="[email protected]";
$pass="CfoLl3";
//Upload a blank cookie.txt to the same directory as this file with a CHMOD/Permission to 777
function login($url,$data){
$login = curl_init();
curl_setopt($login, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT']."/cookie.txt");
curl_setopt($login, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT']."/cookie.txt");
curl_setopt($login, CURLOPT_TIMEOUT, 40000);
curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($login, CURLOPT_URL, $url);
curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($login, CURLOPT_POST, TRUE);
curl_setopt($login, CURLOPT_POSTFIELDS, $data);
ob_start();
return curl_exec($login);
ob_end_clean();
curl_close($login);
unset($login);
}
function grab_page($site){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_TIMEOUT, 40);
curl_setopt($ch, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT']."/cookie.txt");
curl_setopt($ch, CURLOPT_URL, $site);
ob_start();
return curl_exec($ch);
ob_end_clean();
curl_close($ch);
}
function post_data($site,$data){
$datapost = curl_init();
$headers = array("Expect:");
curl_setopt($datapost, CURLOPT_URL, $site);
curl_setopt($datapost, CURLOPT_TIMEOUT, 40000);
curl_setopt($datapost, CURLOPT_HEADER, TRUE);
curl_setopt($datapost, CURLOPT_HTTPHEADER, $headers);
curl_setopt($datapost, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($datapost, CURLOPT_POST, TRUE);
curl_setopt($datapost, CURLOPT_POSTFIELDS, $data);
curl_setopt($datapost, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT']."/cookie.txt");
ob_start();
return curl_exec($datapost);
ob_end_clean();
curl_close($datapost);
unset($datapost);
}
//============================================== ================================================= ==
//============================================= ================================================= ===
$index_page= grab_page(" www.mamba.ru ");
preg_match("/\/",$index_page,$s_post);
$s_post= $s_post[1];
//get token
$crossAuthTokenId= login("https://auth.wambacdn.net/token.json?partnerId=3 ","s_post=".$s_post."&login=".$login."&password=".$pass);
$json= json_decode($ crossAuthTokenId,true);
$AuthToken= $json['crossAuthTokenId'];
//login further
echo login(" www.mamba.ru/ajax/login.phtml?XForm=Login ","crossAuthTokenId=".$AuthToken);
?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Svirsky, 2015-11-12
@e_svirsky

For starters, use code formatting.
This will make your question easier to read and understand.
Here are some examples:
and more

<div class='some-class'>
   some content
</div>

D
danyic, 2016-07-09
@danyic

Good afternoon ? asked the same question, need light at the end of the tunnel

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question