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
(Objective-C) Adobe Analytics Reporting API (1.4)Demonstrates a simple POST of JSON to the Adobe Analytics Reporting API (v1.4)
#import <NSString.h> #import <CkoJsonObject.h> #import <CkoHttp.h> #import <CkoDateTime.h> #import <CkoPrng.h> #import <CkoStringBuilder.h> #import <CkoCrypt2.h> #import <CkoHttpResponse.h> // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. BOOL success; // In this example, replace "rsid" with your report suite id, and update the URL to use the correct endpoint NSString *url = @"https://api.omniture.com/admin/1.4/rest/?method=Report.Queue"; CkoJsonObject *json = [[CkoJsonObject alloc] init]; [json UpdateString: @"reportDescription.reportSuiteID" value: @"rsid"]; [json UpdateString: @"reportDescription.dateGranularity" value: @"hour"]; CkoHttp *http = [[CkoHttp alloc] init]; CkoDateTime *dt = [[CkoDateTime alloc] init]; [dt SetFromCurrentSystemTime]; NSString *timecreated = [dt GetAsTimestamp: NO]; CkoPrng *prng = [[CkoPrng alloc] init]; NSString *nonce = [prng GenRandom: [NSNumber numberWithInt: 12] encoding: @"hex"]; NSString *secret = @"SECRET"; CkoStringBuilder *sb = [[CkoStringBuilder alloc] init]; [sb Append: nonce]; [sb Append: timecreated]; [sb Append: secret]; CkoCrypt2 *crypt = [[CkoCrypt2 alloc] init]; crypt.HashAlgorithm = @"sha1"; crypt.EncodingMode = @"base64"; NSString *digest = [crypt HashStringENC: [sb GetAsString]]; CkoStringBuilder *sbNonce = [[CkoStringBuilder alloc] init]; [sbNonce Append: nonce]; [sbNonce Encode: @"base64"]; [sb Clear]; [sb Append: @"UsernameToken Username=\"USERNAME\", PasswordDigest=\""]; [sb Append: digest]; [sb Append: @"\", Nonce=\""]; [sb Append: [sbNonce GetAsString]]; [sb Append: @"\", Created=\""]; [sb Append: timecreated]; [sb Append: @"\""]; NSLog(@"%@",[sb GetAsString]); [http SetRequestHeader: @"X-WSSE" value: [sb GetAsString]]; CkoHttpResponse *resp = [http PostJson2: url contentType: @"text/json" jsonText: [json Emit]]; if (http.LastMethodSuccess != YES) { NSLog(@"%@",http.LastErrorText); return; } NSLog(@"%@%d",@"Http Status code: ",[resp.StatusCode intValue]); NSLog(@"%@",@"JSON response:"); NSLog(@"%@",resp.BodyStr); |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.