Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Delphi DLL Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text

HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Delphi DLL) Adobe Analytics Reporting API (1.4)

Demonstrates a simple POST of JSON to the Adobe Analytics Reporting API (v1.4)

Chilkat for Delphi Downloads

Chilkat non-ActiveX DLL for Delphi

Chilkat ActiveX DLL for Delphi

* The examples here use the non-ActiveX DLL.

uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, CkDateTime, Prng, HttpResponse, StringBuilder, JsonObject, Crypt2, Http;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
url: PWideChar;
json: HCkJsonObject;
http: HCkHttp;
dt: HCkDateTime;
timecreated: PWideChar;
prng: HCkPrng;
nonce: PWideChar;
secret: PWideChar;
sb: HCkStringBuilder;
crypt: HCkCrypt2;
digest: PWideChar;
sbNonce: HCkStringBuilder;
resp: HCkHttpResponse;

begin
//  This requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

//  In this example, replace "rsid" with your report suite id, and update the URL to use the correct endpoint
url := 'https://api.omniture.com/admin/1.4/rest/?method=Report.Queue';

json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'reportDescription.reportSuiteID','rsid');
CkJsonObject_UpdateString(json,'reportDescription.dateGranularity','hour');

http := CkHttp_Create();

dt := CkDateTime_Create();
CkDateTime_SetFromCurrentSystemTime(dt);
timecreated := CkDateTime__getAsTimestamp(dt,False);

prng := CkPrng_Create();
nonce := CkPrng__genRandom(prng,12,'hex');

secret := 'SECRET';

sb := CkStringBuilder_Create();
CkStringBuilder_Append(sb,nonce);
CkStringBuilder_Append(sb,timecreated);
CkStringBuilder_Append(sb,secret);

crypt := CkCrypt2_Create();
CkCrypt2_putHashAlgorithm(crypt,'sha1');
CkCrypt2_putEncodingMode(crypt,'base64');
digest := CkCrypt2__hashStringENC(crypt,CkStringBuilder__getAsString(sb));

sbNonce := CkStringBuilder_Create();
CkStringBuilder_Append(sbNonce,nonce);
CkStringBuilder_Encode(sbNonce,'base64');

CkStringBuilder_Clear(sb);
CkStringBuilder_Append(sb,'UsernameToken Username="USERNAME", PasswordDigest="');
CkStringBuilder_Append(sb,digest);
CkStringBuilder_Append(sb,'", Nonce="');
CkStringBuilder_Append(sb,CkStringBuilder__getAsString(sbNonce));
CkStringBuilder_Append(sb,'", Created="');
CkStringBuilder_Append(sb,timecreated);
CkStringBuilder_Append(sb,'"');

Memo1.Lines.Add(CkStringBuilder__getAsString(sb));

CkHttp_SetRequestHeader(http,'X-WSSE',CkStringBuilder__getAsString(sb));

resp := CkHttp_PostJson2(http,url,'text/json',CkJsonObject__emit(json));
if (CkHttp_getLastMethodSuccess(http) <> True) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

Memo1.Lines.Add('Http Status code: ' + IntToStr(CkHttpResponse_getStatusCode(resp)));
Memo1.Lines.Add('JSON response:');
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));

CkHttpResponse_Dispose(resp);

CkJsonObject_Dispose(json);
CkHttp_Dispose(http);
CkDateTime_Dispose(dt);
CkPrng_Dispose(prng);
CkStringBuilder_Dispose(sb);
CkCrypt2_Dispose(crypt);
CkStringBuilder_Dispose(sbNonce);

end;

 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.