Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to verify envato purchase code in 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;
    }
}
 
PREVIOUS NEXT
Tagged: #verify #envato #purchase #code #php
ADD COMMENT
Topic
Name
1+5 =