我使用 this 示例尝试向我知道Facebook ID的用户发送FB好友请求(I&# 39;我在应用程序中硬编码了我的FB id
这就是我正在做的事情:
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();
}
如上所示,requestId
始终为空,实际上收到的Bundle
始终为空。
我可能做错了什么?我对这个对话的Session
表示肯定是有效的(我已经检查过了,看起来还可以,它已经打开了所有内容)
想法?
答案 0 :(得分:0)
发现问题。似乎Facebook已经从API 2.0开始删除了“发送好友请求”。