Skip to content

Commit

Permalink
Query Buycraft API with cURL
Browse files Browse the repository at this point in the history
Change Buycraft API query so it uses cURL instead of file_get_contents.
Closes #58
  • Loading branch information
samerton committed Jan 10, 2016
1 parent 45c9b69 commit c8d0eeb
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions addons/Donate/integration/buycraft.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@

$API = $queries->getWhere('donation_settings', array("name", "=", "api_key"));
$API = $API[0]->value;

$bc_payments = file_get_contents('https://api.buycraft.net/v4?action=payments&secret=' . $API);
$bc_payments = json_decode($bc_payments, true);

$bc_packages = file_get_contents('https://api.buycraft.net/v4?action=packages&secret=' . $API);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

// Payments
curl_setopt($ch, CURLOPT_URL, 'https://api.buycraft.net/v4?action=payments&secret=' . $API);
$bc_payments = curl_exec($ch);
$bc_payments = json_decode($bc_payments, true);

// Packages
curl_setopt($ch, CURLOPT_URL, 'https://api.buycraft.net/v4?action=packages&secret=' . $API);
$bc_packages = curl_exec($ch);
$bc_packages = json_decode($bc_packages, true);

$bc_categories = file_get_contents('https://api.buycraft.net/v4?action=categories&secret=' . $API);
// Categories
curl_setopt($ch, CURLOPT_URL, 'https://api.buycraft.net/v4?action=categories&secret=' . $API);
$bc_categories = curl_exec($ch);
$bc_categories = json_decode($bc_categories, true);

?>
curl_close($ch);

0 comments on commit c8d0eeb

Please sign in to comment.