Henrique
Henrique

Reputation: 5011

Send an App Request to a specific user using the Facebook SDK

I'm working on a game that has a "play with your Facebook friends" feature (it does not use Facebook Canvas). The setup is pretty standard. I want to display a list of all of the user's Facebook friends and if they are also users of my app, a "Play" button will show up, if not, an "Invite" button will show up.

To get the list of my Facebook friends which use the app, I make a call to

Request.newMyFriendsRequest

and then to get a list of all of my friends, I make another call to /me/taggable_friends.

With this info, I'm able to create such a list. The issue is that if I want to send an App Request to a user, I need their user id, but the id which is returned by the /me/taggable_friends is not the actual Facebook id of that user, but a unique id associated with my app (as explained in the documentation), so it doesn't work if I want to send an App Request using it.

To invite a friend, I'm using the following code:

Bundle params = new Bundle();
        params.putString("title", "Invite Friend");
        params.putString("message", "has invite has you to try out the game");
        params.putString("to",  id);  // how do I get this id?

        WebDialog requestsDialog = ( new WebDialog.RequestsDialogBuilder(this,
                Session.getActiveSession(), params)).setOnCompleteListener(new WebDialog.OnCompleteListener()
        {
            @Override
            public void onComplete(Bundle values, FacebookException error) {

            }
        }).build();
        requestsDialog.show();

This seems to be a pretty standard setup that I've seen in many games so I know it's possible. Any ideas what I'm doing wrong? Thanks!

Upvotes: 1

Views: 635

Answers (1)

Ming Li
Ming Li

Reputation: 15662

This, AFAIK, is not possible in v2.x of the graph API, and it's not the intent of the taggable_friends endpoint (especially given that there is an invitable_friends endpoint). I think you have 2 options:

  1. Also implement a Canvas app so you can use invitable_friends

  2. Show all friends who are already using the app (via the /friends endpoint), and then have a button that allows users to invite more friends, but without specifying which ones to invite. The dialog that pops up will have a friend selector that allows the user to pick which friends to invite.

Upvotes: 1

Related Questions