2012-03-25 118 views
0

Hy!Android版Facebook發佈更新失敗

我使用easyfacebookandroidsdk(http://www.easyfacebookandroidsdk.com/guide.asp)在Facebook上發佈狀態。

我做了一個FB應用程序,並輸入我的Android密鑰哈希。

我的代碼:

public class FBConnect extends GDActivity implements LoginListener{ 

    private FBLoginManager fbManager; 

    //replace it with your own Facebook App ID 
    String title = "Herr der Ringe"; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     //setContentView(R.layout.main); 
     setTitle("Facebook"); 
     //Bundle extras = getIntent().getExtras(); 
     //title=extras.getString("title"); 
    shareFacebook(); 
    } 
    public void shareFacebook() { 

      //change the permissions according to the function you want to use 
        String permissions[] = { "read_stream","publish_actions" }; 

        //change the parameters with those of your application 
        fbManager = new FBLoginManager(this, R.layout.main, 
            "xxxxxxxxx", permissions); 

        if (fbManager.existsSavedFacebook()) { 
          fbManager.loadFacebook(); 
        } else { 

          fbManager.login(); 
        } 
      } 

      @Override 
      protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
        fbManager.loginSuccess(data); 
      } 

      public void loginFail() { 
        fbManager.displayToast("Login failed!"); 

      } 

      public void logoutSuccess() { 
        fbManager.displayToast("Logout success!"); 
      } 

      public void loginSuccess(Facebook facebook) { 

        //library use example 
        RestApi rest = new RestApi(facebook); 
        try { 

         rest.setStatus("I just watched "+title+" and marked it in TVBrain for Android"); 
         Log.e("XXX FB","OK"); 
        } catch (EasyFacebookError e1) { 
         // TODO Auto-generated catch block 
         Log.e("XXX FB","ERROR"); 
         e1.printStackTrace(); 
        } 



      } 



} 

錯誤:

03-25 23:36:42.358: W/Bundle(931): Key status expected byte[] but value was a java.lang.String. The default value <null> was returned. 
03-25 23:36:42.365: W/Bundle(931): Attempt to cast generated internal exception: 
03-25 23:36:42.365: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[] 
03-25 23:36:42.365: W/Bundle(931): at android.os.Bundle.getByteArray(Bundle.java:1363) 
03-25 23:36:42.365: W/Bundle(931): at com.easy.facebook.android.util.Util.openUrl(Util.java:157) 
03-25 23:36:42.365: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119) 
03-25 23:36:42.365: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100) 
03-25 23:36:42.365: W/Bundle(931): at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72) 
03-25 23:36:42.365: W/Bundle(931): at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33) 
03-25 23:36:42.365: W/Bundle(931): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-25 23:36:42.365: W/Bundle(931): at android.os.Looper.loop(Looper.java:137) 
03-25 23:36:42.365: W/Bundle(931): at android.app.ActivityThread.main(ActivityThread.java:4424) 
03-25 23:36:42.365: W/Bundle(931): at java.lang.reflect.Method.invokeNative(Native Method) 
03-25 23:36:42.365: W/Bundle(931): at java.lang.reflect.Method.invoke(Method.java:511) 
03-25 23:36:42.365: W/Bundle(931): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
03-25 23:36:42.365: W/Bundle(931): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
03-25 23:36:42.365: W/Bundle(931): at dalvik.system.NativeStart.main(Native Method) 
03-25 23:36:42.365: W/Bundle(931): Key access_token expected byte[] but value was a java.lang.String. The default value <null> was returned. 
03-25 23:36:42.369: W/Bundle(931): Attempt to cast generated internal exception: 
03-25 23:36:42.369: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[] 
03-25 23:36:42.369: W/Bundle(931): at android.os.Bundle.getByteArray(Bundle.java:1363) 
03-25 23:36:42.369: W/Bundle(931): at com.easy.facebook.android.util.Util.openUrl(Util.java:157) 
03-25 23:36:42.369: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119) 
03-25 23:36:42.369: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100) 
03-25 23:36:42.369: W/Bundle(931): at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72) 
03-25 23:36:42.369: W/Bundle(931): at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33) 
03-25 23:36:42.369: W/Bundle(931): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-25 23:36:42.369: W/Bundle(931): at android.os.Looper.loop(Looper.java:137) 
03-25 23:36:42.369: W/Bundle(931): at android.app.ActivityThread.main(ActivityThread.java:4424) 
03-25 23:36:42.369: W/Bundle(931): at java.lang.reflect.Method.invokeNative(Native Method) 
03-25 23:36:42.369: W/Bundle(931): at java.lang.reflect.Method.invoke(Method.java:511) 
03-25 23:36:42.369: W/Bundle(931): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
03-25 23:36:42.369: W/Bundle(931): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
03-25 23:36:42.369: W/Bundle(931): at dalvik.system.NativeStart.main(Native Method) 
03-25 23:36:42.369: W/Bundle(931): Key method expected byte[] but value was a java.lang.String. The default value <null> was returned. 
03-25 23:36:42.373: W/Bundle(931): Attempt to cast generated internal exception: 
03-25 23:36:42.373: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[] 
03-25 23:36:42.373: W/Bundle(931): at android.os.Bundle.getByteArray(Bundle.java:1363) 
03-25 23:36:42.373: W/Bundle(931): at com.easy.facebook.android.util.Util.openUrl(Util.java:157) 
03-25 23:36:42.373: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119) 
03-25 23:36:42.373: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100) 
03-25 23:36:42.373: W/Bundle(931): at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72) 
03-25 23:36:42.373: W/Bundle(931): at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33) 
03-25 23:36:42.373: W/Bundle(931): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-25 23:36:42.373: W/Bundle(931): at android.os.Looper.loop(Looper.java:137) 
03-25 23:36:42.373: W/Bundle(931): at android.app.ActivityThread.main(ActivityThread.java:4424) 
03-25 23:36:42.373: W/Bundle(931): at java.lang.reflect.Method.invokeNative(Native Method) 
03-25 23:36:42.373: W/Bundle(931): at java.lang.reflect.Method.invoke(Method.java:511) 
03-25 23:36:42.373: W/Bundle(931): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
03-25 23:36:42.373: W/Bundle(931): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
03-25 23:36:42.373: W/Bundle(931): at dalvik.system.NativeStart.main(Native Method) 
03-25 23:36:42.377: W/Bundle(931): Key format expected byte[] but value was a java.lang.String. The default value <null> was returned. 
03-25 23:36:42.381: W/Bundle(931): Attempt to cast generated internal exception: 
03-25 23:36:42.381: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[] 
03-25 23:36:42.381: W/Bundle(931): at android.os.Bundle.getByteArray(Bundle.java:1363) 
03-25 23:36:42.381: W/Bundle(931): at com.easy.facebook.android.util.Util.openUrl(Util.java:157) 
03-25 23:36:42.381: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119) 
03-25 23:36:42.381: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100) 
03-25 23:36:42.381: W/Bundle(931): at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72) 
03-25 23:36:42.381: W/Bundle(931): at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33) 
03-25 23:36:42.381: W/Bundle(931): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-25 23:36:42.381: W/Bundle(931): at android.os.Looper.loop(Looper.java:137) 
03-25 23:36:42.381: W/Bundle(931): at android.app.ActivityThread.main(ActivityThread.java:4424) 
03-25 23:36:42.381: W/Bundle(931): at java.lang.reflect.Method.invokeNative(Native Method) 
03-25 23:36:42.381: W/Bundle(931): at java.lang.reflect.Method.invoke(Method.java:511) 
03-25 23:36:42.381: W/Bundle(931): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
03-25 23:36:42.381: W/Bundle(931): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
03-25 23:36:42.381: W/Bundle(931): at dalvik.system.NativeStart.main(Native Method) 
03-25 23:36:43.740: W/Bundle(931): Key status expected byte[] but value was a java.lang.String. The default value <null> was returned. 
03-25 23:36:43.744: W/Bundle(931): Attempt to cast generated internal exception: 
03-25 23:36:43.744: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[] 
03-25 23:36:43.744: W/Bundle(931): at android.os.Bundle.getByteArray(Bundle.java:1363) 
03-25 23:36:43.744: W/Bundle(931): at com.easy.facebook.android.util.Util.encodePostBody(Util.java:65) 
03-25 23:36:43.744: W/Bundle(931): at com.easy.facebook.android.util.Util.openUrl(Util.java:184) 
03-25 23:36:43.744: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119) 
03-25 23:36:43.744: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100) 
03-25 23:36:43.744: W/Bundle(931): at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72) 
03-25 23:36:43.744: W/Bundle(931): at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33) 
03-25 23:36:43.744: W/Bundle(931): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-25 23:36:43.744: W/Bundle(931): at android.os.Looper.loop(Looper.java:137) 
03-25 23:36:43.744: W/Bundle(931): at android.app.ActivityThread.main(ActivityThread.java:4424) 
03-25 23:36:43.744: W/Bundle(931): at java.lang.reflect.Method.invokeNative(Native Method) 
03-25 23:36:43.744: W/Bundle(931): at java.lang.reflect.Method.invoke(Method.java:511) 
03-25 23:36:43.744: W/Bundle(931): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
03-25 23:36:43.744: W/Bundle(931): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
03-25 23:36:43.744: W/Bundle(931): at dalvik.system.NativeStart.main(Native Method) 
03-25 23:36:43.744: W/Bundle(931): Key access_token expected byte[] but value was a java.lang.String. The default value <null> was returned. 
03-25 23:36:43.748: W/Bundle(931): Attempt to cast generated internal exception: 
03-25 23:36:43.748: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[] 
03-25 23:36:43.748: W/Bundle(931): at android.os.Bundle.getByteArray(Bundle.java:1363) 
03-25 23:36:43.748: W/Bundle(931): at com.easy.facebook.android.util.Util.encodePostBody(Util.java:65) 
03-25 23:36:43.748: W/Bundle(931): at com.easy.facebook.android.util.Util.openUrl(Util.java:184) 
03-25 23:36:43.748: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119) 
03-25 23:36:43.748: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100) 
03-25 23:36:43.748: W/Bundle(931): at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72) 
03-25 23:36:43.748: W/Bundle(931): at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33) 
03-25 23:36:43.748: W/Bundle(931): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-25 23:36:43.748: W/Bundle(931): at android.os.Looper.loop(Looper.java:137) 
03-25 23:36:43.748: W/Bundle(931): at android.app.ActivityThread.main(ActivityThread.java:4424) 
03-25 23:36:43.748: W/Bundle(931): at java.lang.reflect.Method.invokeNative(Native Method) 
03-25 23:36:43.748: W/Bundle(931): at java.lang.reflect.Method.invoke(Method.java:511) 
03-25 23:36:43.748: W/Bundle(931): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
03-25 23:36:43.748: W/Bundle(931): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
03-25 23:36:43.748: W/Bundle(931): at dalvik.system.NativeStart.main(Native Method) 
03-25 23:36:43.748: W/Bundle(931): Key method expected byte[] but value was a java.lang.String. The default value <null> was returned. 
03-25 23:36:43.752: W/Bundle(931): Attempt to cast generated internal exception: 
03-25 23:36:43.752: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[] 
03-25 23:36:43.752: W/Bundle(931): at android.os.Bundle.getByteArray(Bundle.java:1363) 
03-25 23:36:43.752: W/Bundle(931): at com.easy.facebook.android.util.Util.encodePostBody(Util.java:65) 
03-25 23:36:43.752: W/Bundle(931): at com.easy.facebook.android.util.Util.openUrl(Util.java:184) 
03-25 23:36:43.752: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119) 
03-25 23:36:43.752: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100) 
03-25 23:36:43.752: W/Bundle(931): at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72) 
03-25 23:36:43.752: W/Bundle(931): at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33) 
03-25 23:36:43.752: W/Bundle(931): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-25 23:36:43.752: W/Bundle(931): at android.os.Looper.loop(Looper.java:137) 
03-25 23:36:43.752: W/Bundle(931): at android.app.ActivityThread.main(ActivityThread.java:4424) 
03-25 23:36:43.752: W/Bundle(931): at java.lang.reflect.Method.invokeNative(Native Method) 
03-25 23:36:43.752: W/Bundle(931): at java.lang.reflect.Method.invoke(Method.java:511) 
03-25 23:36:43.752: W/Bundle(931): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
03-25 23:36:43.752: W/Bundle(931): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
03-25 23:36:43.752: W/Bundle(931): at dalvik.system.NativeStart.main(Native Method) 
03-25 23:36:43.752: W/Bundle(931): Key format expected byte[] but value was a java.lang.String. The default value <null> was returned. 
03-25 23:36:43.756: W/Bundle(931): Attempt to cast generated internal exception: 
03-25 23:36:43.756: W/Bundle(931): java.lang.ClassCastException: java.lang.String cannot be cast to byte[] 
03-25 23:36:43.756: W/Bundle(931): at android.os.Bundle.getByteArray(Bundle.java:1363) 
03-25 23:36:43.756: W/Bundle(931): at com.easy.facebook.android.util.Util.encodePostBody(Util.java:65) 
03-25 23:36:43.756: W/Bundle(931): at com.easy.facebook.android.util.Util.openUrl(Util.java:184) 
03-25 23:36:43.756: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatusCall(RestApi.java:119) 
03-25 23:36:43.756: W/Bundle(931): at com.easy.facebook.android.apicall.RestApi.setStatus(RestApi.java:100) 
03-25 23:36:43.756: W/Bundle(931): at com.korn.tvbrain.overview.FBConnect.loginSuccess(FBConnect.java:72) 
03-25 23:36:43.756: W/Bundle(931): at com.easy.facebook.android.facebook.LoggedInThread$1.handleMessage(LoggedInThread.java:33) 
03-25 23:36:43.756: W/Bundle(931): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-25 23:36:43.756: W/Bundle(931): at android.os.Looper.loop(Looper.java:137) 
03-25 23:36:43.756: W/Bundle(931): at android.app.ActivityThread.main(ActivityThread.java:4424) 
03-25 23:36:43.756: W/Bundle(931): at java.lang.reflect.Method.invokeNative(Native Method) 
03-25 23:36:43.756: W/Bundle(931): at java.lang.reflect.Method.invoke(Method.java:511) 
03-25 23:36:43.756: W/Bundle(931): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
03-25 23:36:43.756: W/Bundle(931): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
03-25 23:36:43.756: W/Bundle(931): at dalvik.system.NativeStart.main(Native Method) 

沒有更新出現在Facebook上。 請幫忙。

回答

1

呃,堆棧跟蹤表示你正試圖將一個字符串轉換爲一個字節[],這聽起來像應該工作,但不會。

很難說它發生在哪裏,因爲您使用的是我不熟悉的Facebook API。

跟蹤堆棧跟蹤,直到找到代碼中的調用。然後從那裏開始。

我想說的是在Facebook API中的 Util.openUrl()。這是否期望一個字節[],並傳遞一個字符串?

+0

在官方Facebook API中也存在同樣的缺陷或類似缺陷,在一些地方也存在。儘管easyfacebookandroid不是Android的官方FB SDK,但可能值得查看StackOverflow中處理Facebook官方SDK的一些帖子,因爲邏輯錯誤可能類似。 – scriptocalypse 2012-03-26 00:32:48