I want to try to have Advanced Installer validate a serial number through Gumroad's license key API, and unfortunately, Advanced installer won't allow me to change the POST query name, as instead it wants to POST to a PHP file that contains the query value. Is there a way to translate from AI's sn
query to license_key
? I have combined a PHP file that sends the user inputed key to the PHP file that'll send to gumroad's licensing API
<?php
$request = new HttpRequest();
$request->setUrl('http://api.gumroad.com/v2/licenses/verify');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'product_permalink' => '[GUMROAD_PRODUCT_CODE]',
'license_key' => $sn
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
// server response codes
define('LICENSE_VALID', '200');
define('LICENSE_INVALID', '404');
function ServerResponse($is_valid, $posted_serial = '', $lang_id = 1033)
{
$msg_sep = "\n";
// load error messages from your database, using "$lang_id" for localization (optional)
if($posted_serial == '')
return LICENSE_INVALID . $msg_sep . "Missing Serial Number !";
if($is_valid == true)
return LICENSE_VALID;
else
return LICENSE_INVALID . $msg_sep . "Serial Number: " . $posted_serial . ' is invalid !';
}
else
{
// issue error response
echo ServerResponse(false);
die();
}
?>