(Objective-C) HTTP POST JSON
Demonstrates how to send a JSON POST and get the JSON response.
#import <CkoHttp.h>
#import <NSString.h>
#import <CkoHttpResponse.h>
// This requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code
CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;
NSString *jsonText = @"{\"user\":\"doctoravatar@penzance.com\",\"forecast\":7,\"t\":\"vlIj\",\"zip\":94089}";
// IMPORTANT: Make sure to change the URL, JSON text,
// and other data items to your own values. The URL used
// in this example will not actually work.
CkoHttpResponse *resp = [http PostJson: @"https://json.penzance.org/request" jsonText: jsonText];
if (http.LastMethodSuccess != YES) {
NSLog(@"%@",http.LastErrorText);
}
else {
// Display the JSON response.
NSLog(@"%@",resp.BodyStr);
}
|