简体   繁体   中英

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 . 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. 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?

If so you can find your issue fully documented by Facebook here . 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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