2012-10-12 96 views
2

我有適用於iOS 6的SDK 3.1,用於發佈狀態更新,我有我想在牆上張貼的人的Facebook用戶標識。如何發佈到Facebook iOS SDK 3.1中的朋友牆?

我只是想說「嗨」。只有一個人的牆。 我可以使用「/ [id]/feed」來定位它們的feed,但是我必須提供一個圖形對象?如果我反正使用startForPostWithGraphPath()。

回答

4

我想通了!

首先當然要在這裏實現FBFriendPickerDelegate,除非你已經有了他們的朋友ID。 http://developers.facebook.com/docs/howtos/filter-devices-friend-selector-using-ios-sdk/

那麼重要組成部分,如何發佈到朋友的牆:在計算出來

- (void)facebookViewControllerDoneWasPressed:(id)sender 
{ 
    NSString* fid; 
    NSString* fbUserName; 

    // get facebook friend's ID from selection. just gets 1 right now. 
    for (id<FBGraphUser> user in friendPickerController.selection) 
    { 
     NSLog(@"\nuser=%@\n", user); 
     fid = user.id; 

     fbUserName = user.name; 
    } 

    //Make the post. 
    NSMutableDictionary* params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Join me!", @"message", @"http://itunes.apple.com/my-super-app", @"link", @"My Super App", @"name", nil]; 

    NSLog(@"\nparams=%@\n", params); 

    //Post to friend's wall. 
    [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/feed", fid] parameters:params HTTPMethod:@"POST" 
          completionHandler:^(FBRequestConnection *connection, id result, NSError *error) 
    { 
     //Tell the user that it worked. 
     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Shared" 
                  message:[NSString stringWithFormat:@"Invited %@! error=%@", fbUserName, error] 
                  delegate:nil 
                cancelButtonTitle:@"OK" 
                otherButtonTitles:nil]; 
     [alertView show]; 
    } 
    ]; 

    //Close the friend picker. 
    [self dismissModalViewControllerAnimated:YES]; 
} 
+1

恭喜 - 太糟糕了它是即將禁用的功能,請參閱https://developers.facebook.com/blog/post/2012/10/10/growing-quality-apps-with-open-graph /剩下的唯一方法就是將來的Feed對話框。 – CBroe

+0

感謝您的信息。你知道如何顯示針對朋友牆的Feed對話框嗎? – Curtis

+0

當然,它正好在文檔中,https://developers.facebook.com/docs/reference/dialogs/feed/ - 有關參數的部分。 – CBroe

相關問題