友盟第三方登陆

友盟第三方登陆

#pragma mark 使用第三方登陆需要重写下面两个方法 - (void)applicationDidBecomeActive:(UIApplic ation*)application {

//登陆需要编写 [UMSocialSnsService

applicationDidBecomeActive];
}
#pragma mark 使用第三方的路需要重写两个方法

- (BOOL)application:(UIApplication *)application

openURL:(NSURL *)url sourceApplication:(NSString

*)sourceApplication annotation:(id)annotation

{
return [UMSocialSnsService

handleOpenURL:url wxApiDelegate:nil]; }

#pragma mark 个人资料 点击触发方法 - (void)resumeview
{

if (self.isBig) { [self.bigCodeImageV

removeFromSuperview]; self.isBig = NO;

}else if(!self.isBig) {

UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager

getSocialPlatformWithName:UMShareToSina]; snsPlatform.loginClickHandler(self

,[UMSocialControllerService defaultControllerService],YES,^(UMSocialRe sponseEntity *response){

NSLog(@"response is %@",response);

//如果是授权到新浪微博,SSO之后如果 想获取用户昵称,头像,需要再获取一次账户细腻

[[UMSocialDataService defaultDataService]

requestSocialAccountWithCompletion:^(UMSoc ialResponseEntity *response) {

//获取用户昵称

NSString

*str=[[[response.data objectForKey:@"accounts"]objectForKey:UMSh areToSina]objectForKey:@"username"];

//获取图片地址

NSString

*url=[[[response.data objectForKey:@"accounts"]objectForKey:UMSh areToSina]objectForKey:@"icon"];

// UMSocial AccountEntity *snsAccount =

[[UMSocialAccountManager

socialAccountDictionary]valueForKey:UMShar eToSina];

// NSLog(@" %@",snsAccount);

self.myView.nameL.text =

str; sd_setImageWithURL:[NSURL

[self.myView.imageV URLWithString:url]];

NSString *docPath = [NSSearchPathForDirectoriesInDomains(9, 1,

1)lastObject];

NSString *filePath = stringByAppendingPathComponent:@"user.txt"

//数组写入文件

NSArray *array = [NSArray arrayWithObjects:str,url, nil];

[array writeToFile:filePath atomically:YES];

//字符串写入文件

// [str writeToFile:filePath atomically:YES

encoding:NSUTF8StringEncoding error:nil];

}];

//写入本地 });

}

[docPath ];

posted @ 2015-11-09 15:09  木子东晓东  阅读(199)  评论(0编辑  收藏  举报