简体   繁体   English

使用Facebook登录后,如何检查用户是否允许我的应用发布在Facebook墙上?

[英]How to check that user has allowed my app to post on facebook wall or not after login with facebook?

I am facing a problem regarding facebook sdk in ios . 我在ios中遇到有关facebook sdk的问题。 I made an app that uses facebook login and at the time of login it ask me to allow permission that my app can post on my facebook wall or not. 我制作了一个使用Facebook登录名的应用程序,登录时要求我允许我的应用程序可以在我的Facebook墙上张贴或不发布的权限。 I want to check that permission is allowed by the user or not. 我想检查用户是否允许该权限。 How can I check that. 我该如何检查。 Do you have any idea? 你有什么主意吗?
Thank you! 谢谢!

Try it : 试试吧 :

 NSString *theWholeUrl = [NSString stringWithFormat:@"https://graph.facebook.com/me/permissions?access_token=%@",[[FBSession activeSession] accessToken]];

 NSLog(@"TheWholeUrl: %@", theWholeUrl);

 NSURL *facebookUrl = [NSURL URLWithString:theWholeUrl];

 NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:facebookUrl];
 [req setHTTPMethod:@"GET"];

 NSURLResponse *response;
 NSError *err;
 NSData *responseData = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&err];
 NSString *content = [NSString stringWithUTF8String:[responseData bytes]];

//NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

 SBJSON *json = [SBJSON new];
 NSError *error = nil;
 NSDictionary * dictionary =[json objectWithString:content error:&error];

The accepted answer uses the Graph API but I presume you are using the native iOS Facebook SDK to make things easier? 可接受的答案使用Graph API,但我想您正在使用本机iOS Facebook SDK来简化事情?

If so you can find your issue fully documented by Facebook here . 如果是这样,您可以在此处找到Facebook完全记录的问题。 They cover all the different scenarios, including how to handle declined permissions and how to re-ask for permission when you need it. 它们涵盖了所有不同的方案,包括如何处理被拒绝的权限以及如何在需要时重新请求权限。

The right way to do this with the Graph API is to use User.permissions. 使用Graph API执行此操作的正确方法是使用User.permissions。

https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fpermissions https://developers.facebook.com/tools/explorer/?method=GET&path=me%2活动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM