我可以使用以下内容在用户墙上发布图像:-
if (appDelegate.session.isOpen)
{
FBSession.activeSession = appDelegate.session;
[FBRequestConnection startForUploadPhoto:img
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[self showAlert:@"eCard Posted" result:result error:error];
}];
}
现在的要求是从朋友选择器类中挑选朋友并将图像发布在所选朋友墙/时间线上。
我已将 Friends 选择器类集成如下:-
if (appDelegate.session.isOpen)
{
FBSession.activeSession = appDelegate.session;
if (self.friendPickerController == nil) {
// Create friend picker, and get data loaded into it.
self.friendPickerController = [[FBFriendPickerViewController alloc] init];
self.friendPickerController.title = @"Pick Friends";
self.friendPickerController.delegate = self;
}
[self.friendPickerController loadData];
[self.friendPickerController clearSelection];
[self presentModalViewController:self.friendPickerController animated:YES];
}
现在在委托方法中:-
- (void)facebookViewControllerDoneWasPressed:(id)sender {
// we pick up the users from the selection, and create a string that we use to update the text view
// at the bottom of the display; note that self.selection is a property inherited from our base class
//UIImage *img = self.image;
FBSession.activeSession = appDelegate.session;
for (id<FBGraphUser> user in self.friendPickerController.selection) {
FBSession.activeSession = appDelegate.session;
if (appDelegate.session.isOpen)
{
NSMutableDictionary *postVariablesDictionary = [[NSMutableDictionary alloc] init];
// [postVariablesDictionary setObject:@"me" forKey:@"name"];
// [postVariablesDictionary setObject:self.image forKey:@"picture"];
[postVariablesDictionary setObject:@"Sample Text" forKey:@"message"];
NSLog(@"%@",user.id);
[FBRequestConnection startForPostWithGraphPath:[NSString stringWithFormat:@"%@/feed",user.id] graphObject:[NSDictionary dictionaryWithDictionary:postVariablesDictionary] completionHandler:nil];
}
else
{
if (appDelegate.session.state != FBSessionStateCreated) {
// Create a new, logged out session.
appDelegate.session = [[FBSession alloc] init];
}
// if the session isn't open, let's open it now and present the login UX to the user
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
}];
}
}
[self dismissModalViewControllerAnimated:YES];
}
上面的 Delegate 方法总是导致 Error code =5 facebook sdk error 。应该调用什么 API 才能使上面的图像发布在选定的朋友墙上。
请帮我.......