2010-04-07 15 views
0

我使用下面的Android代码连接到Facebook,但得到以下例外,而不是运行功能onLoginSuccess你好,我使用Android代码来连接Facebook,但得到“Facebook服务器错误+ 104 - 错误的签名”

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(); 
      } 
     } 
    } 
} 

回答

0

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

卡盘

1

我使用FBRocket因为有没有很多关于它的文件有许多问题。

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