2015-10-22 182 views
0

请原谅基本问题,但我很困惑请求Facebook的权限为我的应用程序。我的应用程序允许用户选择照片,然后登录到他们的Facebook页面,并将这些照片发布到他们的时间线上。我正在请求manage_pages,publish_pages和publish_actions。在我的开发人员帐户中,我添加了两位测试人员,他们是我的朋友,我们彻底测试了这个过程。一切都很完美。但是当我创建一个测试用户(Facebook创建一个通用帐户的用户)时,我的应用不会将照片发布到他们的墙上。我授予测试用户相同的权限。我现在想知道是否需要调用user_photos作为另一个请求的权限。我不认为我这样做,因为我不请求访问用户的照片或相册。我只是将照片发布到他们的时间线上,我认为这是publish_pages和publish_actions的作用。你能看看代码,看看你是否能找到我做错了什么?是否需要user_photos?

- (IBAction)facebookButtonClicked1:(id)sender 
{ 


    if ([self.selectedImages count] > 0) 
    { 


    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; 
    login.loginBehavior = FBSDKLoginBehaviorWeb; 
    [login logInWithPublishPermissions:@[@"publish_actions"] 
    fromViewController:self 
    handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { 
     if (error) { 
      NSLog(@"Process error"); 
     } else if (result.isCancelled) { 
      NSLog(@"Cancelled"); 
     } else { 
      NSLog(@"Logged in"); 

      [self shareSegmentWithFacebookComposer]; 


     } 
    }]; 

    } 
    else 
    { 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Photos" message:@"You have not selected any photo." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    [alert show]; 
    } 


} 

-(void)shareSegmentWithFacebookComposer{ 
if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"]) { 
    [self publishFBPost]; //publish 
} else { 
    NSLog(@"no publish permissions"); 
    } 
    } 

    -(void) publishFBPost{ 
NSMutableArray* photos = [[NSMutableArray alloc] init]; 

for (NSString* imageFile in self.selectedImages) { 
    UIImage *image = [UIImage imageWithContentsOfFile:[dataPath stringByAppendingPathComponent:imageFile]]; 
    FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init]; 
    photo.image = image; 
    photo.userGenerated = YES; 

    [photos addObject:photo]; 

} 

FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init]; 
content.photos = [photos copy]; 

[FBSDKShareDialog showFromViewController:self 
    withContent:content 
     delegate:nil]; 
    [FBSDKShareAPI shareWithContent:content delegate:nil]; 

viewThanks.hidden = NO; 
    [NSTimer scheduledTimerWithTimeInterval:4.5 target:self selector:@selector(start) userInfo:nil repeats:NO]; 

FBSDKShareDialog *shareDialog = [FBSDKShareDialog new]; 

[shareDialog setMode:FBSDKShareDialogModeAutomatic]; 
    [shareDialog setShareContent:content]; 
[shareDialog show]; 
} 
+0

是否要将照片发布到用户的个人时间表或他们管理的页面上? – CBroe

+0

我只想在他们的个人时间表上张贴照片,但是如果张贴在他们管理的页面上,它会影响吗? publish_pages覆盖了那个吗? – iSITKiosk

+0

如果您只想发布到用户个人资料,请勿要求提供manage_pages和publish_pages。 – CBroe

回答

0

有publish_stream许可后才能上传照片,但在最新的SDK publish_actions已经取代publish_actions所以你只需要publish_actions。如果你想看到用户的照片,那么你需要user_photos权限。