When I run this piece of code in an individual php file it works fine.
$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;
But if I place it in a larger segment of code I get 500 error?
I often find this when I am using libraries that this annoying problem happens and I can't see any logical reason why this is happening?