2015-01-14 150 views
-1

我使用Facebook sdk 3.0在Facebook牆上發佈圖片。 當我在Facebook牆上發佈圖片時,它只發布來自開發者ID的任何其他ID。在Facebook牆上發佈圖片xcode ios

用戶從他的Facebook帳戶登錄以將照片上傳到他的牆上。如果用戶從開發者帳戶登錄,則圖像張貼在牆上,而來自其他帳戶的圖像不張貼。

-(void)uploadPhoto { 

    if (FBSession.activeSession.isOpen) { 
     [self promptUserWithAccountNameForUploadPhoto]; 
    } else { 
     [FBSession openActiveSessionWithPermissions:permissions 
             allowLoginUI:YES 
            completionHandler:^(FBSession *session, 
                 FBSessionState status, 
                 NSError *error) { 
             if (error) { 
             } else 
           if(FB_ISSESSIONOPENWITHSTATE(status)) 
             { 
              [self promptUserWithAccountNameForUploadPhoto]; 
             } 
            }]; 
    } 
} 

-(void)promptUserWithAccountNameForUploadPhoto { 
    [[FBRequest requestForMe] startWithCompletionHandler: 
    ^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) { 
     if (!error) { 

      UIAlertView *tmp = [[UIAlertView alloc] 
           initWithTitle:@"Upload to FB?" 
           message:[NSString stringWithFormat:@"Upload to ""%@"" Account?", user.name] 
           delegate:self 
           cancelButtonTitle:nil 
           otherButtonTitles:@"No",@"Yes", nil]; 
      tmp.tag = 100; 
      [tmp show]; 

     } 
    }]; 
} 

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 

    if (buttonIndex==1) { 
     if (alertView.tag==100) { 
      [FBRequestConnection startForUploadPhoto:sampleImage 
            completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
             if (!error) { 
              UIAlertView *tmp = [[UIAlertView alloc] 
                   initWithTitle:@"Success" 
                   message:@"Photo Uploaded" 
                   delegate:self 
                   cancelButtonTitle:nil 
                   otherButtonTitles:@"Ok", nil]; 

              [tmp show]; 
             } else { 
              UIAlertView *tmp = [[UIAlertView alloc] 
                   initWithTitle:@"Error" 
                   message:@"Some error happened" 
                   delegate:self 
                   cancelButtonTitle:nil 
                   otherButtonTitles:@"Ok", nil]; 

              [tmp show]; 
             } 

            }]; 

     } 

     if (alertView.tag==200) { 
     [FBRequestConnection startForPostStatusUpdate:myStatus.text completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
       if (!error) { 
        UIAlertView *tmp = [[UIAlertView alloc] 
             initWithTitle:@"Success" 
             message:@"Status Posted" 
             delegate:self 
             cancelButtonTitle:nil 
             otherButtonTitles:@"Ok", nil]; 

        [tmp show]; 
       } else { 
        UIAlertView *tmp = [[UIAlertView alloc] 
             initWithTitle:@"Error" 
             message:@"Some error happened" 
             delegate:self 
             cancelButtonTitle:nil 
             otherButtonTitles:@"Ok", nil]; 

        [tmp show]; 
       } 
      }]; 
     } 
    } 
} 
+0

具有u設置了Facebook您的應用程序在全球** ** –

回答

2

在您的Facebook應用程序中,您可以選擇爲應用程序設置開/關開發者模式。

如果Facebook應用程序不活你只能與開發商張貼佔

+0

我在哪裏可以設置開發模式? – doxsi

+0

@doxsi如果您的應用程序是實時的,則開發人員模式關閉,任何人都可以連接到它。如果沒有,開發者模式是開啓的,只有你可以。要發佈您的fb應用程序,請轉到您的應用程序和應用程序評論,然後從該應用程序生活 –