시나닷컴 iOS SDK 사용자 정보 얻기
1684 단어 시나닷컴이 넓다.
코드
- (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
");
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];
}