Created
May 5, 2012 07:18
-
-
Save magicshui/2600587 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
NSMutableURLRequest *request; | |
NSError *error; | |
NSURLResponse* response; | |
NSData *receivedData; | |
NSString*result; | |
static NSString* url_pic =@"http://douban.fm/misc/captcha?size=m&id="; | |
request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:url_fav_song]]; | |
[request setValue:@"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" forHTTPHeaderField:@"Accept"]; | |
[request setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20100101 Firefox/11.0" forHTTPHeaderField:@"User-Agent"]; | |
receivedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; | |
if (receivedData) { | |
result=[[NSString alloc]initWithData:receivedData encoding:NSUTF8StringEncoding]; | |
} else { | |
// Inform the user that the connection failed. | |
} | |
NSLog(@"receive data: %@",result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment