Search code examples
androidfacebookfacebook-graph-apifacebook-android-sdkfacebook-sdk-3.0

How to tag friends in a wall post using facebbok sdk in android?


I am trying to tag one friend in my wall post. But this 'tags' parameter isn't working. How can i tag one/more friends? Pls help me. Thank you in advance.

            Bundle params = new Bundle();

            params.putString("tags", tagged_friends_id);

             WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(this, Session.getActiveSession(),params))
                        .setOnCompleteListener(new OnCompleteListener() {

                        @Override
                        public void onComplete(Bundle values, FacebookException error) {
                            if (error == null) {
                                final String postId = values.getString("post_id");
                                if (postId != null) {
                                    Toast.makeText(MainActivity.this,"Posted story, id: "+postId, Toast.LENGTH_SHORT).show();
                                } 
                                else {
                                    // User clicked the Cancel button
                                    Toast.makeText(MainActivity.this,  "Publish cancelled", Toast.LENGTH_SHORT).show();
                                }
                            } 
                            else if (error instanceof FacebookOperationCanceledException) {
                                // User clicked the "x" button
                                Toast.makeText(MainActivity.this,  "Publish cancelled", Toast.LENGTH_SHORT).show();
                            } 
                            else {
                                // Generic, ex: network error
                                Toast.makeText(MainActivity.this, "Error posting story", Toast.LENGTH_SHORT).show();
                            }
                        }

                    }).build();
                feedDialog.show();

Solution

  • As Ming have mentioned, you can not tag friends using the Feed Dialog.

    The only way to tag friends in a post, is using the Open Graph Concept- Mention Tagging