iOS 微博 OAuth2.0 分享 文字 + 图片 微博的方法
也是采用两种方法,先放出第一种方法
//https://upload.api.weibo.com/2/statuses/upload.json
//https://api.weibo.com/2/statuses/update.json
NSUserDefaults *info = [NSUserDefaultsstandardUserDefaults];
NSData *imageData = UIImagePNGRepresentation([UIImageimageNamed:@"auth_header.png"]);
NSURL *url = [[NSURLalloc] initWithString:@"https://upload.api.weibo.com/2/statuses/upload.json"];
ASIFormDataRequest *request = [[ASIFormDataRequestalloc] initWithURL:url];
[request addPostValue:SINAAPPKEY forKey:@"source"];
[request addPostValue:@"sina pic test"forKey:@"status"];
[request setData:imageData withFileName:@"auth_header.png"andContentType:@"image/jpeg"forKey:@"pic"];
[request addPostValue:@"0" forKey:@"lat"];
[request addPostValue:@"0" forKey:@"long"];
[request addPostValue:[selfDecrypt:PasswordKey :[info objectForKey:@"sina_access_token"]] forKey:@"access_token"];
[request startSynchronous];
NSString *resultString = [request responseString];
NSDictionary *result = [resultString objectFromJSONString];
NSLog(@"The dic is %@", result);
[request release];
[url release];
使用iOS SDK的方式没有成功,贴几个相关的链接,如果后面有需要再参考
http://aitracy.iteye.com/blog/785402
http://stackoverflow.com/questions/9460817/form-data-request-using-nsurlconnection-in-ios
http://www.oschina.net/code/snippet_12_8203