Not able to verify Purchase Code with Item ID Please help me.

$item_id = 'xxxxxxxxx';
$purchase_code = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';

$header   = array();
$header[] = 'Content-length: 0';
$header[] = 'Content-type: application/json; charset=utf-8';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "".$item_id."&purchase_code=".$purchase_code);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "");
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);



You can check this helpfull reply from @baileyherbert



Yeah, looks like you forgot to authenticate your API request with a personal token. You need to add the Authorization and User-Agent headers per the post linked by @mgscoder:

$header   = array();
$header[] = 'Content-length: 0';
$header[] = 'Content-type: application/json; charset=utf-8';
$header[] = 'Authorization: Bearer PERSONAL_TOKEN_HERE';
$header[] = 'User-Agent: Purchase code verification on';

Here is a fully working code sample for verifying purchase codes, if you want to reference it:


Thank you @baileyherbert & @mgscoder
Your suggestion helps me lot to use API Programmaticaly.
Now, i am confused to use the API for my application.

I wanted to check the purchase code for specific Item.

    Which Application suits for my need.
    Please Suggest me
    Thank you

Neither of those check purchase codes. What you want is the one called “Look up sale by code” (

First, make sure to generate a personal token. This is an API key that will allow you to connect to the Envato API. You cannot connect without it.

Then check this post, it has everything you need in code: How to verify a purchase code using the Envato API