我正在使用facebook sdk 3.0在Facebook墙上发布图片。 当我在Facebook墙上发布图片时,它仅从开发者ID发布而不是任何其他ID。
用户从他的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 :(得分:2)
在您的Facebook应用程序中,您可以选择为您的应用程序设置开/关开发者模式。
如果Facebook应用程序不在线,您只能使用开发者帐户发布