How to send friend request using Facebook dialogs on Android?

前端 未结 2 977
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-17 06:31

I want tot send a friend request using the Facebook Android SDK. I\'m currently using this code (which I got from here):

Bundle parameters = new Bundle();
pa         


        
2条回答
  •  無奈伤痛
    2020-12-17 06:47

    You can use:

    WebDialog.RequestsDialogBuilder requestBuilder = (new WebDialog.RequestsDialogBuilder(this,
                    Session.getActiveSession(), params)).setOnCompleteListener(
                    new OnCompleteListener() {
    
                        @Override
                        public void onComplete(Bundle values,
                                FacebookException error) {
                            if (error != null) {
    
                            } else {
                                final String requestId = values
                                        .getString("request");
                                if (requestId != null) {
                                    //if the user completed the action,
                                } else {
    
                                }
                            }
                        }
    
                    });
            WebDialog requests = requestBuilder.build();
            requests.show();
    

    If you want to set the request to preselected friends just add the following to the requestBuilder:

    requestBuilder.setTo("FRIEND_ID, ANOTHER_FRIEND_ID"), before building the dialog.

    What is strange is that it accepts the list of friends as a concatenated list of ids, not an Array nor list. I didn't find in in the docs, but just found that it works

提交回复
热议问题