Вход в систему Tradedoubler cURL

Я попытался создать сценарий, который может войти в Tradedoubler и перейти по определенному URL после (отчет по EPI).

Когда я пытаюсь запустить следующий код, он не регистрирует меня в tradedoubler, но дает мне страницу «Время сеанса истекло».

Мой код на данный момент выглядит так:

    <?php
// ---- LOGIN ---

$referer = "https://www.tradedoubler.com"; // site main url
$url = "https://login.tradedoubler.com/public/aLogin.action"; // url of login form post too

$ch = curl_init();

$postvars = "tradedoublerUserName=USERNAME&tradedoublerPassword=PASSWORD"; // list the form variables

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);  // HTTPS
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_MUTE, 1); // do not identify client as Curl
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); // fake to be Internet Explorer 6.0
curl_setopt($ch, CURLOPT_POST, 1); // change if GET is used in the form
curl_setopt($ch, CURLOPT_HEADER, 1); // return HTTP header
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars); // send the POST variables separated with &
curl_setopt($ch, CURLOPT_COOKIEJAR, "tmp/cookie.txt");  // autosaves cookies in tmp file

$page = curl_exec($ch); // the returned page
$error = curl_error($ch);

// echo $error."\r\n"; // for debuging purposes

curl_close($ch);

// --- GET PAGE --- (while logged in)

$url = "https://login.tradedoubler.com/pan/aReport3.action?reportName=aAffiliateEPIReport&columns=epi1&columns=totalOrderValue&columns=affiliateCommission&columns=link&columns=timeStamp&startDate=16-04-14&endDate=16-09-14&isPostBack=&metric1.lastOperator=/&interval=&favoriteDescription=&currencyId=DKK&run_as_organization_id=&minRelativeIntervalStartTime=0&includeWarningColumn=true&metric1.summaryType=NONE&epi1=&latestDayToExecute=0&showAdvanced=false&metric1.operator1=/&epi2=&metric1.midFactor=&reportTitleTextKey=REPORT3_SERVICE_REPORTS_AAFFILIATEEPIREPORT_TITLE&setColumns=true&metric1.columnName1=programId&metric1.columnName2=programId&reportPrograms=&metric1.midOperator=/&favoriteName=&affiliateId=&dateType=1&period=custom_period&tabMenuName=&maxIntervalSize=0&favoriteId=&metric1.name=&customKeyMetricCount=0&metric1.factor=&showFavorite=false&view=2&separator=&format=CSV"; // url of the page you want to go to
$referer = "https://login.tradedoubler.com/public/aLogin.action";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // HTTPS
curl_setopt($ch, CURLOPT_REFERER, $referer); // use the loginpage as referer this time
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($ch, CURLOPT_COOKIEFILE, "tmp/cookie.txt"); // load cookies from tmp file$page = curl_exec($ch);
$error = curl_error($ch);

curl_close($ch);

//echo $error."\r\n"; // for debuging purposes

echo $page; // the returned page

?>

1

Решение

Попробуйте этот код: —

    <?php
// ---- LOGIN ---
error_reporting(0);
$referer = "https://www.tradedoubler.com"; // site main url
$url = "https://login.tradedoubler.com/pan/login"; // url of login form post too

$ch = curl_init();

$postvars = "j_username=USERNAME&j_password=PASSWORD&login=Y"; // list the form variables

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);  // HTTPS
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_MUTE, 1); // do not identify client as Curl
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); // fake to be Internet Explorer 6.0
curl_setopt($ch, CURLOPT_POST, 1); // change if GET is used in the form
curl_setopt($ch, CURLOPT_HEADER, 1); // return HTTP header
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars); // send the POST variables separated with &
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__)."/tmp/cookie.txt");  // autosaves cookies in tmp file

$page = curl_exec($ch); // the returned page

$error = curl_error($ch);

// echo $error."\r\n"; // for debuging purposes

curl_close($ch);

// --- GET PAGE --- (while logged in)

$url = "https://login.tradedoubler.com/pan/aReport3.action?reportName=aAffiliateEPIReport&columns=epi1&columns=totalOrderValue&columns=affiliateCommission&columns=link&columns=timeStamp&startDate=16-04-14&endDate=16-09-14&isPostBack=&metric1.lastOperator=/&interval=&favoriteDescription=¤cyId=DKK&run_as_organization_id=&minRelativeIntervalStartTime=0&includeWarningColumn=true&metric1.summaryType=NONE&epi1=&latestDayToExecute=0&showAdvanced=false&metric1.operator1=/&epi2=&metric1.midFactor=&reportTitleTextKey=REPORT3_SERVICE_REPORTS_AAFFILIATEEPIREPORT_TITLE&setColumns=true&metric1.columnName1=programId&metric1.columnName2=programId&reportPrograms=&metric1.midOperator=/&favoriteName=&affiliateId=&dateType=1&period=custom_period&tabMenuName=&maxIntervalSize=0&favoriteId=&metric1.name=&customKeyMetricCount=0&metric1.factor=&showFavorite=false&view=2&separator=&format=CSV"; // url of the page you want to go to
$referer = "https://login.tradedoubler.com/public/aLogin.action";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // HTTPS
curl_setopt($ch, CURLOPT_REFERER, $referer); // use the loginpage as referer this time
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($ch, CURLOPT_COOKIEFILE, "tmp/cookie.txt"); // load cookies from tmp file$page = curl_exec($ch);
$error = curl_error($ch);

curl_close($ch);

//echo $error."\r\n"; // for debuging purposes

echo $page; // the returned page?>
3

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector