Android的Facebook的SDK和URL方法形成成功的朋友对话,但不能承诺方法、朋友、Facebook、Android

2023-09-07 01:30:00 作者:碎流璃

这是一个我开始认为这是一个错误,请,请证明我是错的:

This is one that I'm beginning to think is a bug, please, Please prove me wrong:

我想以编程的朋友用户在Facebook上;他们只是和肯定别人的人都知道IRL。

I want to programmatically friend a user on Facebook; they are only and most certainly someone the person knows IRL.

以下三种解决方案都具有相同的结果:一个成功的朋友们对话 - 这意味着配置文件名称,图片,说明,表明行动(以朋友的人),以及拒绝/确认键; pressing'确认'的问题是:它会导致psented在标准FB UI说Facebook的错误$ P $对不起,出了问题我们正在努力让只要我们可以在这个固定的。我的用户登录和FB应用程序ID(fb_app_id)是金,或片段的父活动就不叫,我的待friended用户名(ID)是金黄色的,他们的个人资料图片确认显示了无论是在我的应用程序,并在好友对话框,动作朋友/是正确的 - '?朋友/给了我一个很好的醇'未找到错误 - 和OnCompleteListener正常工作,甚至周围的消息

The following three solutions all have the same result: a successful friends dialog--meaning the profile name, picture, statement indicating the action( to friend someone ), and refusal/confirm buttons; pressing 'confirm' is the problem: it leads to a Facebook error presented in the standard fb UI saying "Sorry, something went wrong We're working on getting this fixed as soon as we can". My user is logged in and the fb app id( fb_app_id ) is golden, or the fragment's parent activity would not be called, my to-be-friended user id ( Id ) is also golden, confirmed by their profile picture showing up both in my app and in the friends dialog, the action "friends/" is correct--'friends/?' gives me a good ol' "not found" error--and the OnCompleteListener works fine even around the message.

第一种方法是用SDK,如果它的工作我的preferred:

First way is with the SDK, my preferred if it worked:

Bundle params = new Bundle( );
params.putString( "id", Id );
WebDialog requestsDialog = (
new WebDialog.Builder( this.getActivity( ),
        getString( R.string.fb_app_id ),
        "friends/", params )
    .setOnCompleteListener( new CompleteListener( ) )
    .build( ) );
requestsDialog.show( );

保存明确的行动电话,看起来很不错,不是吗?这当然让我来确认对话框;第二种方式是快速和肮脏,但它应该工作:

Save the explicit action call, that looks good, doesn't it? It certainly gets me to the confirmation dialog; second way is quick and dirty, but it should work:

String requestUrl = "https://www.facebook.com/dialog/friends/?id="+
    Id+"&app_id="+getString( R.string.fb_app_id )+
    "&redirect_uri=http://www.facebook.com";
WebDialog requestDialog = new WebDialog( this.getActivity( ), requestUrl );
requestDialog.show( );

但事实并非如此;同样的准成功的结果。第三种方式是我只是检查,以确保我不是白痴,而且基本上是在这个岗位的建议 Facebook朋友对话框返回"未知的方法和QUOT;错误 但与了WebDialogs(我的OnCompleteListener实现),而不是pcated德$ P $库。 同样的事情,同样的信息。

But it doesn't; same quasi-successful result. The third way was me just checking to make sure I wasn't an idiot, and is essentially the suggestion in this post Facebook friends dialog returns "Unknown method" error but with WebDialogs ( my OnCompleteListener implementation ) instead of the deprecated library. Same thing, same message.

这是不是一个真正的错误消息的/对/我,你知道吗?这是一个去precated API调用?是错误消息字面上正确和良好的乡亲FB都意识到这一点?有一些参数实际上,我在这里丢失?它不象他们没有登录!我是那种在这一个我束手无策,在此先感谢您的帮助/咨询/平静的话。 -anb

It's not really an error message that's /for/ me, you know? Is this a deprecated API call? Is the error message literally correct and the good folks at fb are aware of this? Is there some param i'm actually missing here? It's not like they aren't signed in! I'm kind of at my wit's end on this one, thanks in advance for the help/advice/calming words. -AnB

P.S。当你写出来friended看起来真的很有趣。 AB

P.S. 'friended' looks really funny when you write it out. AB

推荐答案

所以,它的是在facebook 的一个错误,一个他们知道,和一个他们不打算修复任何时间很快(在开发人才?战略荒?我会问马克...)。 听到这个dissappointing消息,我又试图链接在Chrome中几种不同的方式,与大惊喜:它工作正常,当你请求桌面版网站的确认屏幕上。

So, it is a bug on facebook, one that they are aware of, and one that they are not going to fix any time soon ( shortage in developer talent? "strategy"? I'll ask Mark... ). Hearing this dissappointing news, I then tried the url in chrome a few different ways, and big surprise: it works fine when you request the desktop site on the confirm screen.

因此​​,有留给我们的移动开发者的一种方式,而且是使囚禁一个web视图与

So, there is one way left to us mobile devs, and that is to make a dialog that jails a webview with

在桌面,似乎用户代理 在一个URL重写停止FB网站从重定向至Intent.ACTION_VIEW

这是我实现(片段):

private void sendRequestDialog( ) {
    String requestUri = "https://www.facebook.com/dialog/friends/?id="+
         Id+"&app_id="+getString(R.string.fb_app_id)+
         "&redirect_uri=http://www.facebook.com";
    WebView webView = new WebView(this.getActivity());
    webView.getSettings().setUserAgentString(getString("Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0"));
    webView.setWebViewClient(new WebViewClient(){
        public boolean shouldOverrideUrlLoading(WebView view, String url){
            return false;
        }
    });
    webView.loadUrl(requestUri);
    AlertDialog.Builder dialog = new AlertDialog.Builder(this.getActivity());
    dialog.setView(webView);
    dialog.setPositiveButton("Done", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();
            }
        });
    dialog.show();

当然,你会希望这些字符串引用,但这个工程,并期待良好的用户界面。

Of course, you'll want to make those strings references, but this works and looks good in the UI.

开始! -anb