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

How to fetch report stats using Bol Api?

我有一个附属 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();
}

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

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

此致, 祖拜尔