Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) Refinitiv World-Check One - Get Top Level GroupsSee more Refinitiv ExamplesSends a signed GET request to get the top level groups. Note: This example requires Chilkat v9.5.0.89 or later.
; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oJson = ObjCreate("Chilkat.JsonObject") Local $bSuccess ; Create the following JSON: ; ; { ; "keyId": "aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", ; "hmacKey": "xxxxzI3vi58xxxCBxxx1+P/d8tGxx7KuLqN/KMPNxxxxekhj8/bx83+1YQSUxxxxYyv939ceY06GvhYRKmxxxx==", ; "algorithm": "hmac-sha256", ; "headers": [ ; "(request-target)", ; "host", ; "date" ; ] ; } ; Substitute your actual API key and API secret in place of "api-key" and "api-secret" $oJson.UpdateString("keyId","api-key") $oJson.UpdateString("hmacKey","api-secret") $oJson.UpdateString("algorithm","hmac-sha256") ; Indicate the names of the headers to be included in the signature. ; "(request-target)" is not actually a header name, but is a special name for HTTP signatures. ; Copy the following three lines of code exactly as-is. ; Do not replace "host", "date", or "(request-target)" with values. $oJson.UpdateString("headers[0]","(request-target)") $oJson.UpdateString("headers[1]","host") $oJson.UpdateString("headers[2]","date") $oHttp = ObjCreate("Chilkat.Http") ; Setting the AuthSignature property causes the following header to be computed and added: ; Authorization: Signature keyId="...", algorithm="hmac-sha256", headers="(request-target) host date", signature="..." $oHttp.AuthSignature = $oJson.Emit() $oHttp.SetRequestHeader "Cache-Control","no-cache" ; Chilkat will auto-add the Date header because it's needed by the HTTP Signature. Local $sResponseJson = $oHttp.QuickGetStr("https://api-worldcheck.refinitiv.com/v2/groups") If ($oHttp.LastMethodSuccess = False) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf ConsoleWrite($sResponseJson & @CRLF) ConsoleWrite("----" & @CRLF) ; A 200 status code indicates success. ConsoleWrite("Status code = " & $oHttp.LastStatus & @CRLF) ; Successful JSON looks like this: ; [ ; { ; "id": "...", ; "name": "Company Name", ; "parentId": null, ; "hasChildren": false, ; "status": "ACTIVE", ; "children": [] ; } ; ] ; Use this online tool to generate parsing code from sample JSON: ; Generate Parsing Code from JSON $oJarr = ObjCreate("Chilkat.JsonArray") $bSuccess = $oJarr.Load($sResponseJson) Local $oJsonObj Local $sId Local $sName Local $sParentId Local $bHasChildren Local $status Local $iJ Local $iCount_j Local $i = 0 Local $iCount_i = $oJarr.Size While $i < $iCount_i $oJsonObj = $oJarr.ObjectAt($i) $sId = $oJsonObj.StringOf("id") $sName = $oJsonObj.StringOf("name") $sParentId = $oJsonObj.StringOf("parentId") $bHasChildren = $oJsonObj.BoolOf("hasChildren") $status = $oJsonObj.StringOf("status") $iJ = 0 $iCount_j = $oJsonObj.SizeOfArray("children") While $iJ < $iCount_j $oJsonObj.J = $iJ $iJ = $iJ + 1 Wend $i = $i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.