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
base64EncodingWithLineLength |
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
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSString *authStr = [NSString stringWithFormat:@"%@:%@", [defaults objectForKey:@"GITHUB_USERNAME"], [defaults objectForKey:@"GITHUB_PASSWORD"]]; | |
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding]; | |
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]]; | |
[theRequest setValue:authValue forHTTPHeaderField:@"Authorization"]; | |
[theRequest setHTTPMethod:@"POST"]; | |
[theRequest setHTTPBody: [bodyString dataUsingEncoding:NSUTF8StringEncoding]]; | |
NSURLConnection *conn = [NSURLConnection connectionWithRequest:theRequest delegate:self]; |
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
sendGistToGitHub:gist withExtension:ext]; | |
} | |
} | |
-(void) sendGistToFI: (NSString *)gist withExtension: (NSString *) ext{ | |
NSString *safeGist = (NSString*)CFURLCreateStringByAddingPercentEscapes(NULL, | |
(CFStringRef)gist, | |
NULL, | |
(CFStringRef)@";/?:@&=+$,", | |
kCFStringEncodingUTF8); |
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
https://gist.github.com/1205340 |
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
nit]; | |
NSString *bodyString = [writer stringWithObject:body]; | |
[writer release]; | |
NSLog(@"%@", bodyString); | |
NSURL *url = [NSURL URLWithString:@"https://api.github.com/gists"]; | |
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSString *authStr = [NSString stringWithFormat:@"%@:%@", [defaults objectForKey:@"GITHUB_USERNAME"], [defaults objectForKey:@"GITHUB_PASSWORD"]]; |
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
tringEncodingUTF8); | |
NSString *body = [NSString stringWithFormat:@"file_contents[gistfile1]=%@&file_ext[gistfile1]=%@", safeGist, ext]; | |
[safeGist release]; | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSString *urlString = [NSString stringWithFormat:@"%@/gists", [defaults stringForKey:@"GIST_URL"]]; | |
NSURL *url = [NSURL URLWithString:urlString]; | |
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; | |
[theRequest setHTTPMethod:@"POST"]; |
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
NSString *safeGist = (NSString*)CFURLCreateStringByAddingPercentEscapes(NULL, | |
(CFStringRef)gist, | |
NULL, | |
(CFStringRef)@";/?:@&=+$,", | |
kCFStringEncodingUTF8); | |
NSString *body = [NSString stringWithFormat:@"file_contents[gistfile1]=%@&file_ext[gistfile1]=%@", safeGist, ext]; | |
[safeGist release]; | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSString *urlString = [NSString stringWithFormat:@"%@/gists", [defaults stringForKey:@"GIST_URL"]]; |
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
NSString *safeGist = (NSString*)CFURLCreateStringByAddingPercentEscapes(NULL, | |
(CFStringRef)gist, | |
NULL, | |
(CFStringRef)@";/?:@&=+$,", | |
kCFStringEncodingUTF8); | |
NSString *body = [NSString stringWithFormat:@"file_contents[gistfile1]=%@&file_ext[gistfile1]=%@", safeGist, ext]; | |
[safeGist release]; | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSString *urlString = [NSString stringWithFormat:@"%@/gists", [defaults stringForKey:@"GIST_URL"]]; |
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
NSString *safeGist = (NSString*)CFURLCreateStringByAddingPercentEscapes(NULL, | |
(CFStringRef)gist, | |
NULL, | |
(CFStringRef)@";/?:@&=+$,", | |
kCFStringEncodingUTF8); | |
NSString *body = [NSString stringWithFormat:@"file_contents[gistfile1]=%@&file_ext[gistfile1]=%@", safeGist, ext]; | |
[safeGist release]; | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSString *urlString = [NSString stringWithFormat:@"%@/gists", [defaults stringForKey:@"GIST_URL"]]; |
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
NSString *safeGist = (NSString*)CFURLCreateStringByAddingPercentEscapes(NULL, | |
(CFStringRef)gist, | |
NULL, | |
(CFStringRef)@";/?:@&=+$,", | |
kCFStringEncodingUTF8); | |
NSString *body = [NSString stringWithFormat:@"file_contents[gistfile1]=%@&file_ext[gistfile1]=%@", safeGist, ext]; | |
[safeGist release]; | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSString *urlString = [NSString stringWithFormat:@"%@/gists", [defaults stringForKey:@"GIST_URL"]]; |
OlderNewer