Created
March 11, 2012 18:51
BoxBilling Licensing server callback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 [email protected] 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