$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, "https://api.envato.com/v3/market/buyer/download?item_id=".$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); curl_close($ch); print_r($output);
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
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 mywebsite.com';
Here is a fully working code sample for verifying purchase codes, if you want to reference it:
I wanted to check the purchase code for specific Item.
Which Application suits for my need.
Please Suggest me
Neither of those check purchase codes. What you want is the one called “Look up sale by code” (https://build.envato.com/api/#market_0_Author_Sale).
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