SHARE
TWEET

Untitled

a guest Nov 6th, 2015 122 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $whiteList = array(
  2.     'codes-que-vous-creez-vous-même-si-besoin-1',
  3.     'codes-que-vous-creez-vous-même-si-besoin-2',
  4.     );
  5.  
  6. $blackList = array(
  7.     'codes-que-vous-souhaitez-bannir (si le mec a piraté votre plugin par ex)-1',
  8.     'codes-que-vous-souhaitez-bannir (si le mec a piraté votre plugin par ex)-2',
  9. );
  10.  
  11. function verify_envato_purchase_code($code_to_verify)
  12. {
  13.     global $whiteList, $blackList;
  14.  
  15.     // Whitelist
  16.     if (in_array($code_to_verify, $whiteList)) {
  17.         return array('verify-purchase' => array('buyer' => true));
  18.     }
  19.  
  20.     // Blacklist
  21.     if (in_array($code_to_verify, $blackList)) {
  22.         return array();
  23.     }
  24.  
  25.     $username = 'votre-username-envato';
  26.     $api_key = 'votre-api-key-envato';
  27.      
  28.     // Open cURL channel
  29.     $ch = curl_init();
  30.      
  31.     // Set cURL options
  32.     $url = "http://marketplace.envato.com/api/edge/". $username ."/". $api_key ."/verify-purchase:". $code_to_verify .".json";
  33.     curl_setopt($ch, CURLOPT_URL, $url);
  34.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  35.     curl_setopt($ch, CURLOPT_USERAGENT, 'API');
  36.     $return = curl_exec($ch);
  37.      
  38.     $output = json_decode($return, true);
  39.     curl_close($ch);
  40.      
  41.     return $output;
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top