Skip to content

Instantly share code, notes, and snippets.

@codemodify
Created January 17, 2019 12:02
Show Gist options
  • Save codemodify/8f3b73c94465a8ae49fe4c402de77e18 to your computer and use it in GitHub Desktop.
Save codemodify/8f3b73c94465a8ae49fe4c402de77e18 to your computer and use it in GitHub Desktop.
qosmicparticles-io-samples-objc.c
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Content-Type": @"application/json" };
NSDictionary *parameters = @{ @"version": @"2.0",
@"key": @"rcd1JN+CkZo2+KKR802bXTujubMbiZARQcyTR8Ku8haqdyaz8pA8Z1kbrWJO2J2CiwFdnr",
@"gobSize": @10 };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://qosmicparticles.io:4444/FetchGobs"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment