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

Objective-C Web API Examples

Primary Categories

ABN AMRO
AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Global Payments
Google Search Console
Hungary NAV Invoicing
Jira
MYOB
Magento

Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
Rabobank
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twilio
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
WhatsApp
Xero
Yousign
_Miscellaneous_
eBay
effectconnect

 

 

 

(Objective-C) Update an Inventory Listing using OAuth1 Authentication

Updates an inventory listing. This example uses OAuth1 authentication instead of providing an api_key=MY_ETSY_KEYSTRING query parameter.

Chilkat Objective-C Library Downloads

MAC OS X (Cocoa) Libs

iOS Libs

#import <CkoRest.h>
#import <CkoOAuth1.h>
#import <NSString.h>
#import <CkoJsonObject.h>

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

CkoRest *rest = [[CkoRest alloc] init];
BOOL success;

CkoOAuth1 *oauth1 = [[CkoOAuth1 alloc] init];

oauth1.ConsumerKey = @"CONSUMERKEY";
oauth1.ConsumerSecret = @"CONSUMERSECRET";
oauth1.Token = @"TOKEN";
oauth1.TokenSecret = @"TOKENSECRET";
oauth1.SignatureMethod = @"HMAC-SHA1";
[oauth1 GenNonce: [NSNumber numberWithInt: 16]];

BOOL autoReconnect = YES;
BOOL tls = YES;
success = [rest Connect: @"openapi.etsy.com" port: [NSNumber numberWithInt: 443] tls: tls autoReconnect: autoReconnect];
if (success == NO) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

// Tell the REST object to use the OAuth1 object.
success = [rest SetAuthOAuth1: oauth1 useQueryParams: YES];

NSString *jsonText = @"[{\"product_id\":1999949999,\"property_values\":[],\"offerings\":[{\"offering_id\":9999905883,\"price\":\"36.23\",\"quantity\":1}]}]";

[rest AddQueryParam: @"products" value: jsonText];
[rest AddHeader: @"Content-Type" value: @"application/x-www-form-urlencoded"];

NSString *jsonResponseText = [rest FullRequestFormUrlEncoded: @"PUT" uriPath: @"/v2/listings/228827035/inventory"];
if (rest.LastMethodSuccess == NO) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse Load: jsonResponseText];
jsonResponse.EmitCompact = NO;

NSLog(@"%@",[jsonResponse Emit]);

NSLog(@"%@%d",@"Response status code: ",[rest.ResponseStatusCode intValue]);
 

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