您的位置:首页 > 移动开发 > IOS开发

新浪微博 iOS SDK获得用户信息

2014-04-14 11:12 218 查看

代码

- (void)getUserInfo {
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:2];
[params setObject:self.wbtoken forKey:@"access_token"];
[params setObject:self.uid forKey:@"uid"];
NSLog(@"params:%@", params);

WBHttpRequest * asiRequest = [WBHttpRequest requestWithURL:@"https://api.weibo.com/2/users/show.json" httpMethod:@"GET" params:params delegate:self withTag:@"getUserInfo"];
}


响应函数

- (void)request:(WBHttpRequest *)request didFinishLoadingWithResult:(NSString *)result
{
NSError *error;
NSData  *data = [result dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
if (json == nil)
{
NSLog(@"json parse failed \r\n");
return;
}
self.screenname = [json objectForKey:@"screen_name"];
self.picture    = [json objectForKey:@"profile_image_url"];

NSLog(self.screenname);
NSLog(self.picture);
m_observer->NotifyAvatarsReceived(avatarData);

NSString *title = nil;
UIAlertView *alert = nil;

title = @"收到网络回调";
alert = [[UIAlertView alloc] initWithTitle:title
message:[NSString stringWithFormat:@"%@",result]
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alert show];
[alert release];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: