我的 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];
}