(Objective-C) qa.factura1.com.co Obtain Auth Token
Demonstrates how to send a JSON POST to get an authenticataion token for qa.factura1.com.co
#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.h>
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
// Build the following JSON
// {
// "password": "MY_PASSWORD",
// "username": "MY_USERNAME"
// }
CkoJsonObject *json = [[CkoJsonObject alloc] init];
json.EmitCompact = NO;
[json UpdateString: @"password" value: @"MY_PASSWORD"];
[json UpdateString: @"username" value: @"MY_USERNAME"];
CkoHttpResponse *resp = [http PostJson3: @"https://qa.factura1.com.co/v2/auth" contentType: @"application/json" json: json];
if (http.LastMethodSuccess == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
CkoJsonObject *jsonResp = [[CkoJsonObject alloc] init];
jsonResp.EmitCompact = NO;
[jsonResp Load: resp.BodyStr];
NSLog(@"%@",[jsonResp Emit]);
NSLog(@"%@%@",@"Access token: ",[jsonResp StringOf: @"token"]);
|