Afzal
Afzal

Reputation: 71

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();

Upvotes: 1

Views: 3053

Answers (3)

Ankita
Ankita

Reputation: 43

You can tag multiple friends using the "tags" key itself. But the syntax needs to be bit different. The friend ids must be appended in a string separated by comma. There should not be any spaces between the ids.

For eg:

params.putString("tags", "xxxxx1,xxxxx2");

This worked perfectly for me.

Upvotes: 1

Sahil Mittal
Sahil Mittal

Reputation: 20753

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

Upvotes: 0

Ming Li
Ming Li

Reputation: 15662

See the documentation for the supported parameters to the Feed dialog here:

https://developers.facebook.com/docs/reference/dialogs/feed/

The Feed dialog does not support "tags".

Upvotes: 0

Related Questions