2015-10-22 179 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權限。