Developer Documentation
  • Introduction
  • Recipes
    • Using Recipes with Lingk APIs
  • Lingk REST APIs
    • Using Postman with Lingk APIs
    • Events & Webhooks
    • Code Samples
      • C#
      • ColdFusion
      • Go
      • Java
      • Node.js
      • PHP
      • Python
      • Salesforce Apex
  • API Explorer
  • API Plugin for Apache Nifi
    • Docker on Windows Installation Guide
    • Colleague Implementation Notes
    • Testing the API Plugin with Postman
Powered by GitBook
On this page

Was this helpful?

  1. Lingk REST APIs
  2. Code Samples

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>
PreviousC#NextGo

Last updated 5 years ago

Was this helpful?