Created
January 17, 2019 12:02
-
-
Save codemodify/8f3b73c94465a8ae49fe4c402de77e18 to your computer and use it in GitHub Desktop.
qosmicparticles-io-samples-objc.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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