private $api_key; private $request;
public function SetAPIKey($api_key) { $this->$api_key = $api_key;
//NOTE: If you're using the self-hosted version of LimeLM (that is, // LimeLM running on your own servers), then replace the URL with your own.
// Almost all users should leave this line unchanged. $this->$request = curl_init('https://wyday.com/limelm/api/rest/'); }
public function CleanUp() { // close curl object curl_close($this->$request); }
public function AddFeature($version_id, $name, $required, $type = null) { $post_data = array( 'method' => 'limelm.feature.add', 'version_id' => $version_id, 'name' => $name, 'required' => $required ? 'true' : 'false' );
if ($type) $post_data['type'] = $type;
return $this->PostRequest($post_data); }
public function DeleteFeature($feature_id) { $post_data = array( 'method' => 'limelm.feature.delete', 'feature_id' => $feature_id );
return $this->PostRequest($post_data); }
public function EditFeature($feature_id, $name = null, $required = null) { $post_data = array( 'method' => 'limelm.feature.edit', 'feature_id' => $feature_id );
if ($name) $post_data['name'] = $name;
if ($required !== null) $post_data['required'] = $required ? 'true' : 'false';
return $this->PostRequest($post_data); }
public function FindPKey($version_id, $email) { $post_data = array( 'method' => 'limelm.pkey.find', 'version_id' => $version_id, 'email' => $email );
return $this->PostRequest($post_data); }
public function GeneratePKeys($version_id, $num_keys = 1, $num_acts = 1, $email = null, $feature_names = null, $feature_values = null) { $post_data = array( 'method' => 'limelm.pkey.generate', 'version_id' => $version_id, 'num_keys' => $num_keys, 'num_acts' => $num_acts );
if ($email) $post_data['email'] = $email;
if ($feature_names) { $post_data['feature_name'] = $feature_names; $post_data['feature_value'] = $feature_values; }
return $this->PostRequest($post_data); }
public function GetPKeyDetails($pkey_id) { $post_data = array( 'method' => 'limelm.pkey.getDetails', 'pkey_id' => $pkey_id );
return $this->PostRequest($post_data); }
public function GetPKeyID($version_id, $pkey) { $post_data = array( 'method' => 'limelm.pkey.getID', 'version_id' => $version_id, 'pkey' => $pkey );
return $this->PostRequest($post_data); }
public function ManualActivation($xml_act_request) { $post_data = array( 'method' => 'limelm.pkey.manualActivation', 'act_req_xml' => $xml_act_request );
return $this->PostRequest($post_data); }
public function SetPKeyDetails($pkey_id, $num_acts = null, $email = null, $feature_names = null, $feature_values = null) { $post_data = array( 'method' => 'limelm.pkey.setDetails', 'pkey_id' => $pkey_id );
if ($num_acts !== null) $post_data['num_acts'] = $num_acts;
if ($email !== null) $post_data['email'] = $email;
if ($feature_names !== null) { $post_data['feature_name'] = $feature_names; $post_data['feature_value'] = $feature_values; }
return $this->PostRequest($post_data); }
public function GenerateTrialExtension($version_id, $is_online, $length, $expires, $customer_id = null, $max_uses = null) { $post_data = array( 'method' => 'limelm.trialExtension.generate', 'version_id' => $version_id, 'is_online' => $is_online ? 'true' : 'false', 'length' => $length, 'expires' => $expires );
if ($is_online) $post_data['max_uses'] = $max_uses;
if ($customer_id !== null) $post_data['customer_id'] = $customer_id;
return $this->PostRequest($post_data); }
public function TestEcho($params) { $params['method'] = 'limelm.test.echo'; return $this->PostRequest($params); }
private function PostRequest($post_data) { if (!$this->$api_key) throw new Exception('You must specify your LimeLM API key and set it using SetAPIKey().');
$post_data['api_key'] = $this->$api_key;
// This section takes the input fields and converts them to the proper format // for an http post. For example: "method=limelm.pkey.find&version_id=100" $post_string = ''; foreach ($post_data as $key => $value) { if (is_array($value)) { foreach ($value as $sub_value) { $post_string .= $key.'[]='.urlencode($sub_value).'&'; } } else $post_string .= $key.'='.urlencode($value).'&'; }
$post_string = rtrim($post_string, '& ');
curl_setopt($this->$request, CURLOPT_HEADER, 0); // eliminate header info from response curl_setopt($this->$request, CURLOPT_ENCODING, ""); // support gzip & deflate responses if available curl_setopt($this->$request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1) curl_setopt($this->$request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data curl_setopt($this->$request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
return curl_exec($this->$request); // execute curl post and store results in $post_response } public function ProdKeys($quantity, $email){ //Note: we put LimeLM in this directory. Change it as needed.
$LimeLM_ApiKey = 'xxxxx';
// the version id is found in the url.// For example http://wyday.com/limelm/version/100/ the version id is '100'. $LimeLM_VersionID = 'xxxxxx';// global $LimeLM_VersionID, $LimeLM_ApiKey;
//$errors = false;
// set your API key $this->SetAPIKey($LimeLM_ApiKey);
//try //{ // Generate the product key - set the number of activations using the quantity $xml = new SimpleXMLElement($this->GeneratePKeys($LimeLM_VersionID, 1, $quantity, $email)); if ($xml['stat'] == 'ok') { foreach ($xml->pkeys->pkey as $pkey) { // add a newline if you're generating more than one key if ($product_keys) $product_keys .= "\r\n";
// set the product key $product_keys .= $pkey['key']."\r\n"; } } else //failure { // use the error code & message $product_keys = $xml->err['code']."-".$xml->err['msg'];//debug_log('Failed to generate product keys: ('.$xml->err['code'].') '.$xml->err['msg'],false); } //} //catch (Exception $e) //{ // debug_log('Failed to generate product keys, caught exception: '.$e->getMessage(),false); //}
return $product_keys; $this->CleanUp();}
$pk = $this->ProdKeys($product['quantity'].$order_info['email']);
i am using this code in opencart order page. when my order confrm it sends email with opencart mail code. but it sends 100 error