Created
September 1, 2014 13:11
-
-
Save hutattedonmyarm/c3f14e6b5662943cac76 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
NSURL *markerURL = [NSURL URLWithString:@"https://api.app.net/posts/marker"]; | |
NSURLResponse *response = nil; | |
NSError *error = nil; | |
NSString *post = [NSString stringWithFormat:@"{ \"name\": \"channel:%d\", \"id\": \"%d\" }", channelID, mesageID]; | |
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; | |
NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]]; | |
NSDictionary *headers = @{@"Content-Type" : @"application/json", @"Content-Length" : postLength}; | |
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:markerURL]; | |
request.HTTPMethod = @"POST"; | |
request.HTTPBody = postData; | |
[request setValue:[NSString stringWithFormat:@"Bearer %@", @"Your user token here"] forHTTPHeaderField:@"Authorization"]; | |
for(NSString *key in [header allKeys]) { | |
[request setValue:header[key] forHTTPHeaderField:key]; | |
} | |
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment