0

I'm using this example to try and send a FB friend request to a user of which I know the Facebook ID (I've hard coded my FB id in the app)

This is what I'm doing:

    fbId = "100000265744136";

    Bundle params = new Bundle();
    params.putString("message", res.getString(R.string.social_media_fb_friend_request_message));
    params.putString("to", fbId);

    try {
        WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(ctx, Session.getActiveSession(), params)).setOnCompleteListener(new OnCompleteListener() {

            @Override
            public void onComplete(Bundle values, FacebookException error) {

                if (error != null) { // ERROR

                    if (error instanceof FacebookOperationCanceledException) {
                        callback.onSocialMediaError(SocialMediaActions.ACTION_FB_FRIEND_REQUEST, SocialMediaErrorCodes.CANCELLED_BY_USER, "request cancelled by pressing Back");
                        hideLoader();
                    } else {
                        callback.onSocialMediaError(SocialMediaActions.ACTION_FB_FRIEND_REQUEST, SocialMediaErrorCodes.NETWORK_ERROR, "request cancelled");
                        hideLoader();
                    }

                } else { // SUCCESS || CANCELLED

                    final String requestId = values.getString("request");
                    if (requestId != null) {
                        callback.onSocialMediaSuccess(SocialMediaActions.ACTION_FB_FRIEND_REQUEST, null);
                        hideLoader();
                    } else { 
                        // IT ALWAYS GOES HERE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                        callback.onSocialMediaError(SocialMediaActions.ACTION_FB_FRIEND_REQUEST, SocialMediaErrorCodes.CANCELLED, "cancelled");
                        hideLoader();
                    }

                }

            }

        }).build();
        requestsDialog.show();
    } catch (Exception e) {
        if (callback != null) {
            callback.onSocialMediaError(SocialMediaActions.ACTION_FB_FRIEND_REQUEST, SocialMediaErrorCodes.UNKNOWN, "dialog: " + e.getMessage());
        }
        hideLoader();
    }

As you can see above, the requestId is always null, in fact the received Bundle is always an empty one.

What could I be doing wrong? I'm positive the Session I gave to the dialogue is a valid one (I've checked it out and it seems okay, it's open and everything)

Ideas ?

AndreiBogdan
  • 10,858
  • 13
  • 58
  • 106
  • Are you aware that the Facebook API has changed? Have you taken that into consideration? I wonder if FB will support you with user ID's in the future -- this should only work if you have registered your app with FB before April this year and it will only work till APril 2015. – Skynet Sep 01 '14 at 12:18
  • hmm ... 'had no idea. I'll study the matter further. thank you. – AndreiBogdan Sep 01 '14 at 12:48

1 Answers1

0

Found the problem. It seems that Facebook has removed the "send friend request" starting from API 2.0.

AndreiBogdan
  • 10,858
  • 13
  • 58
  • 106