Sample code for 30+ languages & platforms
Objective-C

BrickLink OAuth1 using Chilkat REST

See more BrickLink Examples

Demonstrates sending an api.bricklink.com request with OAuth1 authentication using Chilkat REST.

Note: This example requires Chilkat v9.5.0.91 or greater (due to adjustments made within Chilkat to support bricklink OAuth1 needs).

Chilkat Objective-C Downloads

Objective-C
#import <CkoOAuth1.h>
#import <CkoRest.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>

BOOL success = NO;

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

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

oauth1.ConsumerKey = @"Your Consumer Key";
oauth1.ConsumerSecret = @"Your Consumer Secret";
oauth1.Token = @"Your OAuth1 Token";
oauth1.TokenSecret = @"Your Token Secret";
oauth1.SignatureMethod = @"HMAC-SHA1";

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

[rest SetAuthOAuth1: oauth1 useQueryParams: NO];

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

CkoStringBuilder *sbResponse = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"GET" uriPath: @"/api/store/v1/orders?direction=in" sb: sbResponse];
if (success == NO) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

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

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json LoadSb: sbResponse];
json.EmitCompact = NO;
NSLog(@"%@",[json Emit]);