Skip to content

Instantly share code, notes, and snippets.

@boxbilling
Created March 11, 2012 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boxbilling/2017658 to your computer and use it in GitHub Desktop.
Save boxbilling/2017658 to your computer and use it in GitHub Desktop.
BoxBilling Licensing server callback
<?php
/**
* BoxBilling
*
* LICENSE
*
* This source file is subject to the license that is bundled
* with this package in the file LICENSE.txt
* It is also available through the world-wide-web at this URL:
* http://www.boxbilling.com/LICENSE.txt
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@boxbilling.com so we can send you a copy immediately.
*
* @copyright Copyright (c) 2010-2012 BoxBilling (http://www.boxbilling.com)
* @license http://www.boxbilling.com/LICENSE.txt
* @version $Id$
*/
function getLicenseDetails($key)
{
$url = 'http://www.yourdomain.com/boxbilling/api/guest/servicelicense/check';
//$url = 'http://demo.boxbilling.com/api/guest/servicelicense/check'; // use this url to test license on demo.boxbilling.com server
$params = array();
$params['license'] = $key;
$params['host'] = 'hostname';
$params['path'] = dirname(__FILE__);
$params['version'] = '1.0';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
$result = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($code != 200) {
error_log('CURLINFO_HTTP_CODE: '.$code);
}
return json_decode($result, true);
}
$json = getLicenseDetails('test');
if(!$json['valid']) {
print $json['error'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment