Skip to content

Instantly share code, notes, and snippets.

@jan-koch
Created March 25, 2017 18:18
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 jan-koch/866f6126e11614e2d71803677dd9b18b to your computer and use it in GitHub Desktop.
Save jan-koch/866f6126e11614e2d71803677dd9b18b to your computer and use it in GitHub Desktop.
function wpi_check_with_license_server() {
$license = get_option( 'youroptionfield' );
$api_params = array(
'slm_action' => 'slm_check',
'secret_key' => VALIDATION_KEY,
'license_key' => $license,
);
// Send query to the license manager server
$response = wp_remote_get(add_query_arg($api_params, LICENSE_SERVER), array('timeout' => 20, 'sslverify' => false));
if (is_wp_error($response)){
echo "Unexpected Error! The query returned with an error.";
}
//var_dump($response);//uncomment it if you want to look at the full response
// License data.
$license_data = json_decode(wp_remote_retrieve_body($response));
if( 'success' == $license_data->result ){ //Success was returned for the license activation
// Mark license as valid
update_option( 'youroptionfield', 'true');
} else {
// Mark license as invalid
update_option( 'youroptionfield', 'false');
}
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment