Skip to content

Instantly share code, notes, and snippets.

@debonx
Created November 17, 2018 08:56
Show Gist options
  • Save debonx/cd36779c4857f811319fb0db4abacaba to your computer and use it in GitHub Desktop.
Save debonx/cd36779c4857f811319fb0db4abacaba to your computer and use it in GitHub Desktop.
Woocommerce API manager call example. Retrieves informations about digital products and subscriptions.
/**
*
* Check Status Of License Activation
* More at https://docs.woocommerce.com/document/woocommerce-api-manager/
* @author: huraji (https://xilab.com/u/huraji)
* @param: $Request (string)
* @param: $Endpoint (string)
* @return: JSON decoded formatted data
*
**/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$Body = array();
$License = $this->get_data( 'license' );
$License = $License['license'];
if(!empty($License['api_key']) && !empty($License['api_email']) && !empty($License['api_instance'])){
$this->Api_Request = $Request;
$this->Api_endpoint = $Endpoint;
$this->Api_key = $License['api_key'];
$this->Api_email = $License['api_email'];
$this->Api_instance = $License['api_instance'];
$this->Platform = str_replace("https://", "", $this->Site);
$this->Platform = str_replace("/", "", $this->Platform);
$this->ProductId = urlencode($this->Name);
$url = $this->Site . '?wc-api=' . $this->Api_endpoint . '&email=' . urlencode($this->Api_email) . '&licence_key=' . $this->Api_key . '&request=' . $this->Api_Request . '&product_id=' . $this->ProductId . '&instance=' . $this->Api_instance . '&platform=' . $this->Platform . '&software_version=' . $this->Ver;
$Response = wp_remote_get( $url );
$Body = json_decode(wp_remote_retrieve_body($Response), true);
}
return $Body;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment