是否需要user_photos?

时间:2015-10-22 04:36:45

标签: ios facebook facebook-graph-api

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

  - (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];
}

1 个答案:

答案 0 :(得分:0)

有上传照片的publish_stream权限,但最新的SDK publish_actions 已取代publish_actions,因此您只需要publish_actions。如果你想看到用户的照片,那么你需要user_photos权限。