2012-05-27 144 views
2

是否有可能在用戶朋友牆上發佈內容,而不必先獲取所有朋友(所以你可以獲得朋友ID)?Facebook API:發佈在朋友牆上

[facebook requestWithGraphPath:@"me/friends" andDelegate:self]; 
+1

只有當你知道朋友身份證..但你想做什麼?在我看來,在某些時候你正在展示一位朋友,以便用戶真正知道他/她正在發送消息,對嗎? –

+0

我想要一個名爲「與朋友分享這個按鈕」的按鈕...所以如果你可以在顯示所有朋友的facebook api中獲得一個列表,那麼這將很好,然後你可以檢查你想要的列表分享信息,並公平的分享.. – BlackMouse

+0

好的...好吧,使用您發佈的電話來獲取所有的朋友,並將標識符存儲在一個陣列中,以便您可以向他們發送消息... –

回答

3

看到這個

-(IBAction)PostToBuddyWall 
{ 

NSMutableDictionary *postVariablesDictionary = [[NSMutableDictionary alloc] init]; 


[postVariablesDictionary setObject:@"LOL" forKey:@"name"];  
[postVariablesDictionary setObject:self.postTextView.text forKey:@"message"]; 


[objDelegate.facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/feed",friendId] andParams:postVariablesDictionary andHttpMethod:@"POST" andDelegate:nil]; 

NSLog(@"message: %@",postVariablesDictionary); 
[postVariablesDictionary release]; 

UIAlertView *facebookAlter=[[UIAlertView alloc] initWithTitle:@"Message" message:@"Posted successfully on facebook" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil, nil]; 
[facebookAlter show]; 
[facebookAlter release]; 

[self dismissModalViewControllerAnimated:YES];  
} 
+0

真的不好顯示一個成功的戒備,甚至沒有確定它確實是成功的。爲此使用FB委託方法。 –

+0

感謝您的回覆。但是,通過這種方法,您必須知道朋友ID ...我想處理所有在facebook popup API中的所有內容? – BlackMouse

3

您可以通過向me/friends發出請求來獲取登錄用戶的好友。
然後,您可以創建一個顯示朋友列表的用戶界面元素,用戶可以選擇他想要共享的元素。

然後,在用戶選擇後,您只需發佈POST到FRIEND_ID/feedFeed connection of the User object)即可在牆上張貼。
你需要有publish_stream權限,它可以讓你:Enables your app to post content, comments, and likes to a user's stream and to the streams of the user's friends(http://developers.facebook.com/docs/authentication/permissions/)

相關問題