Skip to content

Instantly share code, notes, and snippets.

@gertig
Created June 6, 2012 15:12
Show Gist options
  • Save gertig/2882520 to your computer and use it in GitHub Desktop.
Save gertig/2882520 to your computer and use it in GitHub Desktop.
Send some data to the server for logging purposes
#pragma mark - Logging User Session Info
- (void)logToServer:(NSString *)reason thisInfo:(NSDictionary *)data
{
UIDevice *device = [UIDevice currentDevice];
NSString *deviceName = [device model];
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSString *userId = [NSString stringWithFormat:@"%d", self.getMyUserId];
NSString *liveEventId = [NSString stringWithFormat:@"%d", self.getEventId];
NSString *urlString = [NSString stringWithFormat:kLoggingURL, self.player.authentication_token];
NSURL *url = [NSURL URLWithString:urlString];
__unsafe_unretained ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:userId forKey:@"log[user_id]"];
[request setPostValue:liveEventId forKey:@"log[live_event_id]"];
[request setPostValue:deviceName forKey:@"log[device_model]"];
[request setPostValue:reason forKey:@"log[reason]"];
[request setPostValue:appVersion forKey:@"log[app_version]"];
[request addRequestHeader:@"Accept" value:@"text/javascript"];
[request startAsynchronous];
}
@gertig
Copy link
Author

gertig commented Jun 6, 2012

Add kLoggingURL to Constants.h

define kLoggingURL @"http://mysite.com/logs?token=%@"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment