Skip to content

Instantly share code, notes, and snippets.

@hutattedonmyarm
Created September 1, 2014 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hutattedonmyarm/c3f14e6b5662943cac76 to your computer and use it in GitHub Desktop.
Save hutattedonmyarm/c3f14e6b5662943cac76 to your computer and use it in GitHub Desktop.
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