当我在一个单独的php文件中运行这段代码时,它可以正常工作。
$ip = '*****';
$account_id = '*****';
$account_email = '*****';
//INITIALIZE MAXMIND
include_once 'src/maxmind/minfraud.phar';
use MaxMind\MinFraud;
//FORM THE MAXMIND REQUEST
$mf = new MinFraud(1234567, 'abcdefghijk');
$score_request = $mf->withDevice([
'ip_address' => $ip,
])->withEvent([
'type' => 'survey',
])->withAccount([
'user_id' => $account_id,
])->withEmail([
'address' => $account_email,
]);
//To get the minFraud Score response model, use ->score():
$score_response = $score_request->score();
//And then you'd grab $scoreResponse->ip_address->risk for the IP risk (if you're just passing the IP address), or $scoreResponse->riskScore if you are passing additional fields.
$risk_score = $score_response->riskScore;
echo $risk_score;
但如果我将它放在更大的代码段中,我会得到500错误?
当我使用库时,我经常发现这个烦人的问题发生了,而且我看不出为什么会发生这种情况的原因?