简体   繁体   中英

Facebook api and send invite to more than one friend in android

I have a problem with inviting firend by facebook api to my app. This is my method:

    private void inviteFromFacebook(Activity activity, List<GraphUser> list) {
        for(int i=0; i<list.size(); i++) {
            //TODO post invite to friends wall
//          Log.v("MainActivity", "user id: " + user.getId());

            if(list == null || list.size() == 0)        
                return;

            Bundle parameters = new Bundle();

            String friendsIdsInFormat = "";

            friendsIdsInFormat = friendsIdsInFormat + list.get(i).getId();

            parameters.putString("to", friendsIdsInFormat);
            parameters.putString( "message", "Use my app!");

            Facebook mFacebook = new Facebook( getResources().getString(R.string.facebook_app_id));
            // 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 onCancel() {
                    // 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

                }
            });
        }
    }

Everyting is ok, but I want to send invitation to many frieds, so in this codes I show one dialog for every person. How can I show only one dialog, but with many friends? This is possible or I must for every friend show dialog?

You can send a comma delimited list in the "to" field, like "123,456,789".

Be careful about sending too many requests though, you don't want to be identified as a spam app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM