如何使用Bol Api获取报告统计信息?

时间:2018-10-10 13:06:27

标签: php curl affiliate

我有一个会员Bol帐户,并且每天通过使用脚本登录并将结果导入我的数据库中来获取交易报告统计信息。

最近,登录表单已更改并应用了验证码。

我通过发送CSRF令牌以及登录详细信息来更改了代码段。它工作了几天,但现在也停止了工作。

这是代码详细信息;

$url = "https://login.bol.com/login?client_id=apm";
$csrf_token_field_name = "csrftoken";
$params =   array(
            "j_username" => 'myusername',
            "j_password" => 'mypassword',
            "submit" => " Inloggen"
        );

$token_cookie= realpath("test.txt");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64) 
AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 
Chrome/32.0.1700.107 Safari/537.36');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $token_cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $token_cookie);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
if (curl_errno($ch)) die(curl_error($ch));
libxml_use_internal_errors(true);
$dom = new DomDocument();
$dom->loadHTML($response);
libxml_use_internal_errors(false);
$tokens = $dom->getElementsByTagName("input");
for ($i = 0; $i < $tokens->length; $i++) 
{
 $meta = $tokens->item($i);
 if($meta->getAttribute('name') == 'csrftoken')
    $t = $meta->getAttribute('value');
}

if($t) {
$csrf_token = file_get_contents(realpath("another-cookie.txt"));
// Setting up post information
$postinfo = "";
foreach($params as $param_key => $param_value) 
{
    $postinfo .= $param_key ."=". $param_value . "&";   
}
$postinfo .= $csrf_token_field_name ."=". $t;
curl_setopt($ch, CURLOPT_URL, 
"https://login.bol.com/j_spring_security_check");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
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_COOKIEJAR, $token_cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $token_cookie);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
curl_setopt($ch, CURLOPT_REFERER, 
"https://partner.bol.com/partner/index.do");
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 260);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);

ob_start();
$html = curl_exec($ch);
$result = curl_getinfo($ch);
ob_get_clean();
}

1 个答案:

答案 0 :(得分:0)

分享以下信息,以帮助其他面临相同问题的人。

解决方案::与bol技术团队联系后,我们需要从Nederland获得服务器,或者将硬编码ip设置为Nederland,导致captch隐藏并继续登录表单。

关于, 祖拜尔