您好我使用Android代码连接Facebook,但得到“Facebook服务器错误+ 104 - 不正确的签名”

时间:2010-04-07 10:46:29

标签: android facebook

我使用下面的Android代码连接到Facebook但获得以下异常而不是运行函数onLoginSuccess

  

Facebook服务器错误+ 104 - 签名不正确

public class FacebookConnection extends Activity implements LoginListener {

    private FBRocket fbRocket;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // You need to put in your Facebook API key here:
        fbRocket = new FBRocket(this, "test", "e2c8deda78b007466c54f48e6359e02e");


        // Determine whether there exists a previously-saved Facebook:
        if (fbRocket.existsSavedFacebook()) {
            String str =fbRocket.getAPIKey();
            Log.e("Api key", str);
            fbRocket.loadFacebook();


         } else {
            fbRocket.login(R.layout.main);
            String str =fbRocket.getAPIKey();
            Log.e("Api key", str);
        }

    }

    public void onLoginFail() {
        fbRocket.displayToast("Login failed!");
        fbRocket.login(R.layout.main);
    }

    public void onLoginSuccess(Facebook facebook) {
        fbRocket.displayToast("Login success!******************");

        // Set the logged-in user's status:
        try {

            facebook.setStatus("I am using Facebook -- it's great!");

            String uid = facebook.getFriendUIDs().get(0); // Just get the uid of the first friend returned...
            fbRocket.displayDialog("Friend's name: " + facebook.getFriend(uid).name); // ... and retrieve this friend's name.

        } catch (ServerErrorException e) {
            // Check if the exception was caused by not being logged-in:
            if (e.notLoggedIn()) {
                // ...if it was, then login again:
                fbRocket.login(R.layout.main);
            } else {
                System.out.println(e);
                e.printStackTrace();
            }
        }
    }
}

3 个答案:

答案 0 :(得分:1)

我使用FBRocket遇到了很多问题,因为关于它的文档不多。

尝试在Facebook站点中将您的Facebook应用程序编辑为“桌面应用程序”,而不是“Web应用程序”。你必须去“高级” - >申请类型

答案 1 :(得分:0)

我有完全相同的问题,但在不同的地方。在做了大量的挖掘之后,我发现对fbRocket.loadFacebook()的调用是罪魁祸首。即使我在手动登录后使用facebook.save()将会话保存到磁盘,我也无法使用该方法。我只能想到fbRocket.loadFacebook()不能正常工作,你应该总是使用fbRocket.login()。这就是我在我的应用程序中必须做的事情。我也无法使用FBRocket网站上的示例代码。希望有所帮助。

答案 2 :(得分:-1)

public class FacebookConnection extends Activity implements LoginListener {

    private FBRocket fbRocket;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // You need to put in your Facebook API key here:
        fbRocket = new FBRocket(this, "test", "e2c8deda78b007466c54f48e6359e02e");


        // Determine whether there exists a previously-saved Facebook:
        if (fbRocket.existsSavedFacebook()) {
            String str =fbRocket.getAPIKey();
            Log.e("Api key", str);
            fbRocket.loadFacebook();


         } else {
            fbRocket.login(R.layout.main);
            String str =fbRocket.getAPIKey();
            Log.e("Api key", str);
        }

    }

    public void onLoginFail() {
        fbRocket.displayToast("Login failed!");
        fbRocket.login(R.layout.main);
    }

    public void onLoginSuccess(Facebook facebook) {
        fbRocket.displayToast("Login success!******************");

        // Set the logged-in user's status:
        try {

            facebook.setStatus("I am using Facebook -- it's great!");

            String uid = facebook.getFriendUIDs().get(0); // Just get the uid of the first friend returned...
            fbRocket.displayDialog("Friend's name: " + facebook.getFriend(uid).name); // ... and retrieve this friend's name.

        } catch (ServerErrorException e) {
            // Check if the exception was caused by not being logged-in:
            if (e.notLoggedIn()) {
                // ...if it was, then login again:
                fbRocket.login(R.layout.main);
            } else {
                System.out.println(e);
                e.printStackTrace();
            }
        }
    }
}