我正在将 Facebook SDK 实施到我的应用程序中。我正在使用 FBLoginView 登录 Facebook。我有一个UIButton
,我用来在用户的 Facebook 墙上分享。现在我不想使用 FBLoginView 登录,我想检查是否有 Facebook 应用程序,以及用户是否已登录。
- (IBAction)pickFriendsList:(UIButton *)sender
{
FBFriendPickerViewController *friendPickerController = [[FBFriendPickerViewController alloc] init];
friendPickerController.title = @"Pick Friends";
[friendPickerController loadData];
// Use the modal wrapper method to display the picker.
[friendPickerController presentModallyFromViewController:self animated:YES handler:
^(FBViewController *sender, BOOL donePressed) {
if (!donePressed) {
return;
}
NSString* fid;
NSString* fbUserName;
for (id<FBGraphUser> user in friendPickerController.selection)
{
NSLog(@"\nuser=%@\n", user);
fid = user.id;
fbUserName = user.name;
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"test", @"message", @"http://webecoist.momtastic.com/wp-content/uploads/2009/01/nature-wonders.jpg", @"picture", @"Sample App", @"name",fid,@"tags",fid,@"to",@"106377336067638",@"place", nil];
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/feed",fid] parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection,id result,NSError *error)
{
[FBWebDialogs presentFeedDialogModallyWithSession:nil parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if (error)
{
// Error launching the dialog or publishing a story.
NSLog(@"Error publishing story.");
}
else
{
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
NSLog(@"User canceled story publishing.");
}
else
{
// Handle the publish feed callback
//Tell the user that it worked.
}
}
}];
}];
}
}];
}