Jak zweryfikować kod zakupu Envato w PHP
function verify_purchase_code($code) {
$code = urlencode($code);
$url = "https://envato.eduardofiorini.com/index.php?item=35215272&code=" . $code . "&domain=" . $_SERVER['HTTP_HOST'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_HTTPHEADER, Array('Content-type: application/json'));
$ret = curl_exec($ch);
curl_close($ch);
if (!$ret) {
$ret = file_get_contents($url);
}
$data = json_decode($ret??"{}",true);
if($data["error"]){
echo json_encode(array("success" => false, "message" => $data["msg"]));
exit();
}else{
return true;
}
}
Codelone