Facebook IOS SDK 可选权限
Posted
技术标签:
【中文标题】Facebook IOS SDK 可选权限【英文标题】:Facebook IOS SDK optional permissions 【发布时间】:2012-05-21 10:19:37 【问题描述】:我的 ios 应用程序向用户询问“publish_stream”权限,问题是当出现可选权限屏幕并且用户单击允许时,facebook sdk 不会执行此操作,因为该应用程序可以在用户墙上发布。当我检查 facebook 帐户上的设置时,我看到“代表您发布”权限存在。这是代码:
NSArray* permissions = [[NSArray alloc] initWithObjects:@"publish_stream", @"email",
@"user_birthday",@"user_relationships", @"user_location", @"user_hometown", nil];
-(void)loginToFacebook
[facebook authorize:permissions];
- (void)fbDidLogin
NSLog(@"did login");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebookAgent accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebookAgent expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
[facebook requestWithGraphpath:@"me/permissions" andDelegate:self];
- (void)request:(FBRequest *)request didLoad:(id)result
NSLog(@"%@",result);
如果用户在可选权限页面中单击 Allow non,则 request:didLoad 方法的结果是:
data = (
"create_note" = 1;
email = 1;
installed = 1;
"photo_upload" = 1;
"publish_actions" = 1;
"publish_stream" = 1;
"share_item" = 1;
"status_update" = 1;
"user_birthday" = 1;
"user_hometown" = 1;
"user_location" = 1;
"user_relationships" = 1;
"video_upload" = 1;
);
这是邮政编码:
-(void)publishToFacebook
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"Name", @"name",
@"Caption", @"caption",
@"Message", @"message",
@"http://url...", @"link",
@"http://imageUrl...", @"picture", nil];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithDictionary:attachment];
[facebook requestWithGraphPath:@"me/feed"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
【问题讨论】:
旁注:以上代码对 Facebook iOS SDK 3.x 不再有效 【参考方案1】:感谢这篇文章。与此相关的错误已提交至 https://developers.facebook.com/bugs/111727002307769 它正在被分配。一旦我们把它修好,你应该很高兴。感谢您的耐心等待。
【讨论】:
以上是关于Facebook IOS SDK 可选权限的主要内容,如果未能解决你的问题,请参考以下文章
ios 应用程序的用户是不是可以使用 facebook-sdk 在 facebook 上喜欢 URL?