Facebook上的朋友对话框返回"未知的方法和QUOT;错误对话框、错误、方法、朋友

2023-09-12 22:05:54 作者:笑谈心酸

所以,我一直在尝试这一点,因为许多天。找不到任何东西任何地方。

So I have been trying this since many days. Could not find anything anywhere.

当我尝试打电话给朋友与Facebook的Andr​​oid SDK的对话框中,它返回这个错误:

When I try to call the Friends dialog with Facebook Android SDK it return this error:

API错误code:3   API错误说明:未知的方法   错误信息:不支持此方法对于这款显示器类型

API Error Code: 3 API Error Description: Unknown method Error Message: This method isn't supported for this display type

我没有找到文档页面,告知未对触摸设备允许的朋友对话框什么。我现在用的是下面的code要做到这一点:

I didn't find anything on documentation pages telling that friends dialog is not allowed on touch devices. I am using the following code to do this:

Bundle params = new Bundle();
params.putString("id", "brent");
Log.i("In on click", params.toString());
SampleDialogListener());
mFacebook.dialog(TestActivity.this, "friends", params, new SampleDialogListener());

如果它不容许有从应用程序中发送好友请求任何其他方式?

If it's not allowed is there any alternative way to send a friend request from within an application?

推荐答案

根本的问题是,Facebook的API还没有准备好所有的显示类型,和对话无法显示的移动显示的朋友。你可以做的是改变了Facebook的机器人库:如果您使用的m.facebook.com在打开的对话​​框中,适当的窗口将出现在弹出显示模式,而不是触摸和www.facebook.com,而不是Facebook的图书馆的标准的WebView。

The underlying problem is that the Facebook API is not yet ready for all the display types, and the friends dialog cannot be shown for the mobile display. What you can do is to change the Facebook android library: if you use "popup" display mode instead of "touch" and www.facebook.com instead of m.facebook.com while opening the dialog, a proper window will appear in the Facebook librarys standard WebView.

对于这一点,改变Facebook.java的对话框功能如下:

For this, change the dialog function of Facebook.java as follows:

protected static String DIALOG_BASE_URL = "https://m.facebook.com/dialog/";
protected static String DIALOG_BASE_URL_FOR_MISSING_SCREENS = "https://www.facebook.com/dialog/";

public void dialog(Context context, String action, Bundle parameters,
        final DialogListener listener) {

    boolean missingScreen = action.contentEquals("friends") ? true : false;

    String endpoint = missingScreen ? DIALOG_BASE_URL_FOR_MISSING_SCREENS : DIALOG_BASE_URL;
    endpoint += action;

    parameters.putString("display", missingScreen ? "popup" : "touch");
    parameters.putString("redirect_uri", REDIRECT_URI);

    if (action.equals(LOGIN)) {
        parameters.putString("type", "user_agent");
        parameters.putString("client_id", mAppId);
    } else {
        parameters.putString("app_id", mAppId);
    }

    if (isSessionValid()) {
        parameters.putString(TOKEN, getAccessToken());
    }
    String url = endpoint + "?" + Util.encodeUrl(parameters);
    if (context.checkCallingOrSelfPermission(Manifest.permission.INTERNET)
            != PackageManager.PERMISSION_GRANTED) {
        Util.showAlert(context, "Error",
                "Application requires permission to access the Internet");
    } else {
        new FbDialog(context, url, listener).show();
    }
}

之后,你可能想要删除该对话框中双击标题栏为好。去FbDialog.java,并插入类似的东西onPageFinished:

After that you might want to remove the double title bar from the dialog as well. Go to FbDialog.java, and insert something similar to onPageFinished:

if (url.contains("friends?")) {
    mTitle.setHeight(0);
    mTitle.setVisibility(View.INVISIBLE);
}