"; echo "
"; // Set the timezone to UTC for 1WorldSync API call date_default_timezone_set("UTC"); $currentDateTime = new DateTime(); echo "Current DateTime: [".$currentDateTime->format('Y-m-d H:i:s')."]
"; $appID = "abc123xy"; // Please update with your APP ID here (8 characters) echo "AppID: [".$appID."]
"; $secretKey = "qwertyuiosdfghjkfghjkfghj1232321"; // Please update with your Secret Key here (32 characters) $gln = "1234567890123"; // Please update with your 13-digit GLN here (13 digits) echo "GLN: [".$gln."]
"; $timeStamp = $currentDateTime->format('Y-m-d\TH:i:s\Z'); $timeStampEnc = urlencode($timeStamp); echo "TimeStampEnc: [".$timeStampEnc."]
"; $uri = "/V1/product/fetch?timestamp=".$timeStamp."&pageSize=1"; $hash = hash_hmac('sha256', $uri, $secretKey, true); $hashInBase64 = base64_encode($hash); echo "HashBase64: [".$hashInBase64."]
"; $hashInBase64URIencoded = urlencode($hashInBase64); echo "HashEnc: [".$hashInBase64URIencoded."]
"; echo "URL: [".'https://content1-api.1worldsync.com/V1/product/fetch?timestamp='.$timeStampEnc.'&pageSize=1'."]
"; echo "
"; $url = 'https://content1-api.1worldsync.com/V1/product/fetch?timestamp='.$timeStampEnc.'&pageSize=1'; $curl = curl_init(); curl_setopt_array($curl, array ( CURLOPT_URL => 'https://content1-api.1worldsync.com/V1/product/fetch?timestamp='.$timeStampEnc.'&pageSize=1', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => '{ }', CURLOPT_HTTPHEADER => array ( 'Content-Type: application/json', 'appId: '.$appID, 'hashcode: '.$hashInBase64 ), )); $response = curl_exec($curl); curl_close($curl); echo "API Response: [".$response."]
"; echo "
"; echo "End API Call
"; ?>