0
I’m trying to get data from Themeforest templates using the API of Envato; need data as template name and price from product ID. But the answer via Curl is that there is an error in the formation. I cannot identify the problem, my experience with Curl, JSON and Apis is limited.
What am I wearing:
$url = 'https://api.envato.com/v1/market/item-prices:'. $theme_id .'.json';
$personal_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
if (extension_loaded('curl') === true) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36");
curl_setopt($ch, CURLOPT_HEADER, array('Authorization: Bearer '.$personal_token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$data = curl_exec($ch);
$err_status = curl_error($ch);
if(curl_exec($ch) === false) {
$err = 'Erro: ' . curl_error($ch);
curl_close($ch);
echo $data;
}
else {
curl_close($ch);
echo 'Completo sem erros: ';
print_r($data);
}
}
The exact answer is:
"error": "Missing or malformed API token: You need to provide an API token to access the API. The token must be a 32 Character long alphanumeric string.