Created
June 30, 2014 07:02
-
-
Save minsOne/4c170095a5c3b2ef7c7a 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
| - (NSString *)encodeURL:(NSString *)url { | |
| NSString * encoded = (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes( | |
| NULL, | |
| (__bridge CFStringRef)url, | |
| NULL, | |
| (CFStringRef)@"!*'();:@&=+$,/?%#[]", | |
| kCFStringEncodingUTF8); | |
| return encoded; | |
| } | |
| // _data = [[NSMutableData alloc] init]; | |
| // NSMutableURLRequest *request; | |
| // NSString *longUrl = @"http://www.google.com/"; | |
| // | |
| // request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.googleapis.com/urlshortener/v1/url"] | |
| // cachePolicy:NSURLRequestReloadIgnoringLocalCacheData | |
| // timeoutInterval:60.0]; | |
| // | |
| // [request setHTTPMethod:@"POST"]; | |
| // [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; | |
| // [request setHTTPBody:[[NSString stringWithFormat:@"{\"longUrl\": \"%@\"}", longUrl] dataUsingEncoding:NSUTF8StringEncoding]]; | |
| // | |
| // [NSURLConnection connectionWithRequest:request delegate:self]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment