forked from FileShuttle/fileshuttle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MVURLShortener.m
executable file
·30 lines (25 loc) · 1.03 KB
/
MVURLShortener.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// MVURLShortener.m
// FileShuttle
//
// Created by Michael Villar on 12/11/11.
//
#import "MVURLShortener.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
@implementation MVURLShortener
///////////////////////////////////////////////////////////////////////////////////////////////////
- (NSString*)shortenURL:(NSString*)url {
NSString *shttleUrl = [NSString stringWithFormat:
@"http://is.gd/create.php?format=simple&url=%@",url];
NSString *doc = [NSString stringWithContentsOfURL:[NSURL URLWithString:shttleUrl]
encoding:NSUTF8StringEncoding error:nil];
if(doc == nil) return nil;
if([doc isEqual: @"Error: Please enter a valid URL to shorten"]) {
return nil;
} else {
return doc;
}
}
@end