如何通过Android上的“我的应用程序”向Facebook好友发送邀请。
最佳答案
你可以这样做:
public void inviteFriends(Activity activity, ArrayList<FriendInfo> friendsIds){
// Safe programming
if(friendsIds == null || friendsIds.size() == 0)
return;
Bundle parameters = new Bundle();
// Get the friend ids
String friendsIdsInFormat = "";
for(int i=0; i<friendsIds.size()-1; i++){
friendsIdsInFormat = friendsIdsInFormat + friendsIds.get(i) + ", ";
}
friendsIdsInFormat = friendsIdsInFormat + friendsIds.get(friendsIds.size()-1).getId();
parameters.putString("to", friendsIdsInFormat);
parameters.putString( "message", "Use my app!");
// Show dialog for invitation
mFacebook.dialog(activity, "apprequests", parameters, new Facebook.DialogListener() {
@Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
}
@Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
}
@Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
}
@Override
public void onCancel() {
// TODO Auto-generated method stub
}
});
}
Facebook dialog reference