TheMasterGeneral Posted May 17, 2016 Share Posted May 17, 2016 Greetings MWG! Recently, [uSER=65371]sniko[/uSER] made mention of FraudGuard.IO in this thread. Personally, I'm not the greatest at PHP, so my knowledge on the subject itself is quite limited. I'm trying to implement the API of Fraudguard into a project I'm working on. Did a few hours of reading PHP manual and random googling, and came up with an almost completed CURL query. $params=['username'=>'minenotyours', 'password'=>'suoytonenim']; $defaults = array( CURLOPT_URL => "https://api.fraudguard.io/ip/1.1.1.1", CURLOPT_POST => false, CURLOPT_POSTFIELDS => $params, CURLOPT_SSL_VERIFYPEER => false, ); $ch = curl_init(); curl_setopt_array($ch, $defaults); if(!curl_exec($ch)){ die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch)); } Anyway, this results in a "Whoops, looks like something went wrong" error, which tells me the request was sent successfully. (As its a result straight from the API itself.) I don't think it has an issue to do with the $parmas being invalid, as the API itself says it'd return a Bad Authentification error if that was the case. Has anyone used this API before, or am I treading alone here? :D Any help would be appreciated. Edit: I'm open to the idea of not having to use curl if needed. Quote Link to comment Share on other sites More sharing options...
IllegalPigeon Posted May 17, 2016 Share Posted May 17, 2016 (edited) Fun fact; Fraudguards API is written with Lumen, Laravel's micro-framework. Which is why you get the error "Whoops, looks like something went wrong" (typical Laravel). Anyhow, it would be ideal for you to write a class, to better handle errors. But, if (as you say), you're not the greatest with PHP, this could prove a little difficult. This will work: $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.fraudguard.io/ip/1.1.1.1', CURLOPT_USERPWD => 'username:password' )); $resp = curl_exec($curl); var_dump($resp); Edited May 17, 2016 by IllegalPigeon Removed un-needed code 1 Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted May 17, 2016 Author Share Posted May 17, 2016 Worked very nicely, Pigeon. Had to add "CURLOPT_SSL_VERIFYPEER => false" to the options array to have it work, but I knew that'd happen. Thanks dude! Quote Link to comment Share on other sites More sharing options...
IllegalPigeon Posted May 17, 2016 Share Posted May 17, 2016 Anytime. :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.