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 ?