无法检索访问令牌对于Facebook上的实际设备 [英] Unable to retrieve access token for facebook on real device

查看:171
本文介绍了无法检索访问令牌对于Facebook上的实际设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目做了Facebook的整合,一切都很好的模拟器。当谈到在真实设备上运行它不工作。我认为这个问题是Facebook的访问令牌,我不知道该怎么做呢?所以,我无法获取真实设备的朋友的信息。任何人可以帮助我如何获得访问令牌上真实的设备。

I did Facebook integration in my project, everything is fine on emulator. When it comes to run on real device it is not working. I think the problem is Facebook access token, I don't know what to do now? So I am unable to retrieve friends information on real device. Can anybody help me how to get access token on real device.

我使用Android SDK中只拿到Facebook的好友信息。

I am using Android SDK only to get the Facebook friends information.

mFacebook = new Facebook("api_id");
mFacebook.authorize(this, new String[] {
    "publish_stream", "read_stream", "offline_access", "friends_birthday", "user_birthday", "email", "read_friendlists", "manage_friendlists"
}, this);
sToken = mFacebook.getAccessToken();
public void onComplete(Bundle values) {
    Log.e("oncomplete", "value");
    if (values.isEmpty()) {
        Log.e("oncomplete", "value is empty");
        return;
    }
    if (!values.containsKey("POST")) {
        sToken = mFacebook.getAccessToken();
        getFriends()
    }
}
private void getFriends() {
    try {
        sToken = mFacebook.getAccessToken();
        StaticUtils.sResponseId = mFacebook.request("me/friends");
        Log.w("response", StaticUtils.sResponseId);
        try {
            JSONObject jObj = Util.parseJson(StaticUtils.sResponseId);
            JSONArray jArr = jObj.getJSONArray("data");
            for (int i = 0; i < jArr.length(); i++) {
                JSONObject jObjFren = jArr.getJSONObject(i);
                Iterator it = jObjFren.keys();
                while (it.hasNext()) {
                    String s = (String) it.next();
                    // Log.w("KEY",s);
                    String sname = jObjFren.getString(s);
                    if (s.equals("id")) {
                        StaticUtils.sFbId.add(sname);
                        StaticUtils.sFbPics.add(StaticUtils.sImgUrl + sname + "/picture");
                    } else if (s.equals("name")) {
                        StaticUtils.sFbName.add(sname.toLowerCase());
                    }
                }
            }
        } catch (JSONException e) {
            Log.w("json exception", e.toString());
        } catch (FacebookError e) {
            Log.w("facebook exception", e.toString());
        }
    } catch (MalformedURLException e) {
        Log.w("malformed exception", e.toString());
    } catch (IOException e) {
        Log.w("io exception", e.toString());
    }
}  

谢谢, Ammu

Thanks, Ammu

推荐答案

在code上面给出的是绝对正确的......现在的问题是,如果我们已经安装在我们的设备中的任何Facebook应用程序,这是升级版本要比我们使用我们的应用程序将无法正常工作......如果我们卸载我们的设备的Facebook应用程序,将工作......而且也有另一种方式通过以下步骤来我们在我们的设备应用程序和其他Facebook应用程序::: 如果u - [R使用eclipse然后转到

The code above given is absolutely correct...The problem is if we have already installed any facebook application in our device which are upgraded versions than we are using our application will not work...If we uninstall the facebook applications in our device it will work...and there is also another way to work our application and other facebook application in our device by following steps::: if u r using eclipse then goto

窗口> preferences>安卓>生成并获得调试密钥库的路径

Windows>Preferences>Android>Build and get the path of the debug keystore

现在打开终端,运行以下命令

now open terminal and run the following command

密钥工具-export -alias androiddebugkey -keystore调试密钥库路径| OpenSSL的SHA1 -binary | OpenSSL的ENC -a -e

keytool -export -alias androiddebugkey -keystore "debug keystore path" | openssl sha1 -binary | openssl enc -a -e

它会要求输入密码,然后输入Android作为乌拉圭回合的密码  现在添加散列键位于你的Facebook API配置@ http://www.facebook.com/developers/ 在编辑设置/移动和设备的屏幕。

it will ask for the password then enter android as ur password Now add the HASH KEY to your Facebook API configuration located @ http://www.facebook.com/developers/ under EDIT SETTINGS / Mobile and Devices screen.

现在我能够运行我的HTC设备上的应用程序

Now i was able to run my application on HTC device

这篇关于无法检索访问令牌对于Facebook上的实际设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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