FB SDK不工作的OS 7 [英] FB SDK not working on OS 7

查看:127
本文介绍了FB SDK不工作的OS 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的app.I的一个实施FB我使用的jar 0.8.25。从5至7.1.And所有模拟器设备其工作罚款仅适用于OS 5和6,但不工作的设备7 7.1.For OS 7登录成功后,它仍然FB页面不重定向回。当我preSS后退按钮,我得到错误遇到无法刷新访问令牌重试按钮。

I am implementing FB in one of my app.I am using jar 0.8.25. Its working fine on all simulators from 5 to 7.1.And for devices works only for OS 5 and 6 but not working on device 7 and 7.1.For OS 7 after log in success it remains on FB page it doesn't redirect back. and when i press back button, i get error encountered unable to refresh access token with try again button.

在控制台上分析它从来没有发现访问令牌单时间OS 7.while 5和6的工作完美。

When analyzing on console it never finds access token single time for OS 7.while for 5 and 6 its working perfectly.

请告诉一下可能会导致问题。

Please tell what may cause the issue.

谢谢,

推荐答案

这是不是你的具体问题的解决方案。我在我使用的接口注释提及。所以我在这里张贴作为其太多的评论部分。它也不是完整的解决方案,您将需要处理的流程和过期的令牌,这只是告诉你我是如何做到这一点的逻辑。

This isn't a solution to your specific problem. I mentioned in the comments that I'm using an interface. So I'm posting here as its too much for the comment section. It is also not the COMPLETE solution, you will need to handle the flow and expired tokens, this is just to show you the logic of how I did this.

有关我的界面我打开一个browserfield到的Oauth网址:
<$c$c>https://www.facebook.com/dialog/oauth?client_id=<APP_ID>&response_type=token&redirect_uri=http://www.facebook.com/connect/login_success.html&scope=publish_actions

For my interface I open a browserfield to the Oauth url: https://www.facebook.com/dialog/oauth?client_id=<APP_ID>&response_type=token&redirect_uri=http://www.facebook.com/connect/login_success.html&scope=publish_actions

和我一个侦听器添加到这个浏览器监听登录后的重定向。一旦你的访问令牌,你要坚持它,并关闭browserfield。

And I add a listener to this browser to listen for the redirects after login. Once you have the access token, you should persist it and close the browserfield.

private class OAuthScreen extends MainScreen
    {
        BrowserField browser_field;
        LoadingDialog loading_dialog;

        public OAuthScreen(final Command task)
        {
            super(VERTICAL_SCROLL | HORIZONTAL_SCROLL);
            BrowserFieldConfig browserConfig = new BrowserFieldConfig();
            browserConfig.setProperty(BrowserFieldConfig.VIEWPORT_WIDTH, new Integer(Display.getWidth()));

            browser_field = new BrowserField(browserConfig);
            browser_field.addListener(new BrowserFieldListener()
            {
                public void documentCreated(BrowserField browserField, ScriptEngine scriptEngine, Document document) throws Exception
                {
                    int index = browserField.getDocumentUrl().indexOf("#access_token=");
                    if (index == -1)
                    {
                        super.documentCreated(browserField, scriptEngine, document);
                    }
                    else
                    {
                        access_token = browserField.getDocumentUrl().substring(index + "#access_token=".length(), browserField.getDocumentUrl().indexOf("&"));

                        PersistentObject store = PersistentStore.getPersistentObject(STORE_KEY);
                        FacebookTokens store_tokens = new FacebookTokens();
                        store_tokens.access_token = access_token;
                        store.setContents(store_tokens);
                        store.commit();

                        if (task != null) task.execute();
                        OAuthScreen.this.close();
                    }
                }

                public void documentLoaded(BrowserField browserField, Document document) throws Exception
                {
                    super.documentLoaded(browserField, document);
                    loading_dialog.close();
                }
            });
            // whatever loading dialog you want, this sometimes takes a while to open
            loading_dialog = LoadingDialog.push(loading_field);

            add(browser_field);
            browser_field.requestContent("https://www.facebook.com/dialog/oauth?client_id="+APP_ID+"&response_type=token&redirect_uri=http://www.facebook.com/connect/login_success.html&scope=publish_actions");
        }
    }

回调的任务仅仅是,如果我想在登录后直接进行通话。

The callback task is just for if I want to perform a call directly after login.

现在只是执行API调用,你需要他们。 API方法在这里 https://developers.facebook.com/docs/graph -API /参考/ 2.0 /
需要访问令牌的方法,应该有它附加到URL,例如, https://graph.facebook.com/me/feed?access_token=+的access_token

Now just perform API calls as you need them. API methods here https://developers.facebook.com/docs/graph-api/reference/v2.0/ Methods that require the access token, should have it appended to the url such as, https://graph.facebook.com/me/feed?access_token=" + access_token

注意清除访问令牌不会清除存储在浏览器领域的令牌。并且将意味着你无法登录在下一次(因为浏览器仍然登录)。
所以,如果你想退出你需要清除本地访问令牌之前开在browserfield此链接<$c$c>\"https://www.facebook.com/logout.php?next=http://www.facebook.com/connect/login_success.html&access_token=\" +的access_token
清除浏览器就足够了的饼干,但我还没有找到一种方式来做到这一点。

Be aware that clearing your access token won't clear the token stored in the browser field. And will mean that you can't login next time (because the browser is still logged in). So if you want to logout you need to open this link in a browserfield before clearing your local access token "https://www.facebook.com/logout.php?next=http://www.facebook.com/connect/login_success.html&access_token=" + access_token Clearing the cookies of the browser should suffice, but I haven't found a way to do this.

这篇关于FB SDK不工作的OS 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆