ColdFusion

<html>
 <body style="font-family:arial">

<CFSCRIPT>
    key = "[your key]";
    secret = "[your secret]";

    currentDate = DateConvert("local2utc", now());
    currentDate = dateTimeFormat(currentDate, 'EEE, dd mmm yyyy HH:nn:ss', "GMT");
    currentDate = currentDate & " GMT";

    endpoint =  "https://www.lingkapis.com";
    service =  "/v1/@self/ps/courses";
    method =  "get";

    message =  "date: " & currentDate & "\n(request-target): " & method & " " & service;

    // Use new built-in Hmac() method.
    sigAsHex = hmac( message, secret, "HMACSHA1", "utf-8");

    sig = binaryEncode( binaryDecode(sigAsHex, "hex"), "base64" );

</CFSCRIPT>
<br>
<cfset authHeader = "Signature keyId=""#key#"",headers=""date (request-target)"",algorithm=""hmac-sha1"",signature=""#URLEncodedFormat(sig)#""">
<cfoutput>#authHeader#</cfoutput>
<br>
<cfhttp method="#method#" url="#endpoint##service#" result="result">
    <cfhttpparam type="header" name="Authorization" value="#authHeader#" />
    <cfhttpparam type="header" name="Date" value="#currentDate#" />    
</cfhttp>

<cfdump var="#result#" />

</body>
</html>

Last updated