新浪微博 iOS SDK获得用户信息
-
代码
12345678- (
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"
];
}
响应函数
1234567891011121314151617181920212223242526272829- (
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];
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。