在FBML如果您使用的是friend-selector你可以傳遞一個數組exclude_ids。如果您使用api查找已在使用應用程序的用戶朋友,則可以通過這種方式排除它們。
這也適用於multi-friend-selector它位於一個fb:request-form標籤內。
EDIT:用戶排除陣列可通過API調用Friends.getAppUsers來獲得。
以下示例使用.NET Facebook Developer Toolkit。 (主要是因爲這就是我以前做過!)
後面的代碼:
public string CURRENT_USER_FRIENDS = "";
//Call this function on pageload or where you like
private void PopulateFriendsData()
{
//exclude friends who already have the app from the inviter
string UsersToExclude = string.Empty;
IList<long> AppUserFriends = this.Master.API.friends.getAppUsers();
foreach (long L in AppUserFriends)
{
UsersToExclude += L.ToString() + ",";
}
CURRENT_USER_FRIENDS = UsersToExclude.TrimEnd(',');
}
PAGE:
<fb:multi-friend-selector
actiontext="Select the friends you want to invite"
rows="3"
exclude_ids="<%=CURRENT_USER_FRIENDS%>"/>
我如何添加這些ID的它是在頁面sourece和我設置除了代碼之外,不會知道用戶朋友,所以我可以在後面的代碼中設置這些ID嗎?我在asp.net 2008下使用C#並且多朋友選擇器是FBML標籤而不是HTML標籤,我可以從後面的代碼傳遞它的屬性值我該怎麼做? – Ahmy 2009-06-16 14:51:34