使用Android在s / one的墙上发布时发出警告

时间:2011-11-16 14:59:53

标签: android facebook facebook-wall

我使用此代码在某人的墙上发布

try{
                mPrefs = getPreferences(MODE_PRIVATE);
                String access_token = mPrefs.getString("access_token", null);
                long expires = mPrefs.getLong("access_expires", 0);
                facebook = new Facebook(FB_APP_ID);
                mAsyncRunner = new AsyncFacebookRunner(facebook);

                if(access_token != null) {
                    Log.d("ACCESS TOKEN", "Access Token != null");
                    facebook.setAccessToken(access_token);
                }
                if(expires != 0) {
                    facebook.setAccessExpires(expires);
                }

                if(!facebook.isSessionValid()) { 
                    synchronized(facebook){


                        facebook.authorize(FBWallWriterActivity.this,  new String[] {"read_stream", "publish_stream", "offline_access", "user_birthday", "friends_birthday"}, 
                                new MyDialogListener());
                    }
                }

                synchronized (facebook) {

                    while(mPrefs.getString("access_token", null) == null){

                        facebook.wait();
                    }

                    String token = mPrefs.getString("access_token", null);
                    Bundle parameters = new Bundle();
                    JSONObject attachment = new JSONObject();

                    try {
                        attachment.put("message", "Messages");

                    } 
                    catch (JSONException e) {
                        Log.e("FBWallWriterAct", "Error "+e.getMessage());

                    }

                    parameters.putString("message", wallMsg.getText().toString());

                    mAsyncRunner.request(uid+"/feed", parameters, "POST", new RequestListener(){

                        public void onComplete(String response, Object state) {
                            Log.d("text","facebook post complete");

                        }

                        public void onIOException(IOException e, Object state) {
                            Log.d("text","facebook post onIOException");
                        }

                        public void onFileNotFoundException(FileNotFoundException e, Object state) {
                            Log.d("text","facebook post onFileNotFoundException");
                        }

                        public void onMalformedURLException(MalformedURLException e, Object state) {
                            Log.d("text","facebook post onMalformedURLException");
                        }

                        public void onFacebookError(FacebookError e, Object state) {
                            Log.d("text","facebook post error");
                        }

                    }, null);

                }
            }

当我尝试发布消息时,这里是我获取的日志:

    11-16 15:59:26.289: W/Bundle(15907): <!>android.os.Bundle 775<!> Key message expected byte[] but value was a java.lang.String.  The default value <null> was returned.
11-16 15:59:26.289: W/Bundle(15907): Attempt to cast generated internal exception:
11-16 15:59:26.289: W/Bundle(15907): java.lang.ClassCastException: java.lang.String
11-16 15:59:26.289: W/Bundle(15907):    at android.os.Bundle.getByteArray(Bundle.java:1317)
11-16 15:59:26.289: W/Bundle(15907):    at com.facebook.android.Util.openUrl(Util.java:155)
11-16 15:59:26.289: W/Bundle(15907):    at com.facebook.android.Facebook.request(Facebook.java:563)
11-16 15:59:26.289: W/Bundle(15907):    at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
11-16 15:59:26.299: W/Bundle(15907): <!>android.os.Bundle 775<!> Key access_token expected byte[] but value was a java.lang.String.  The default value <null> was returned.
11-16 15:59:26.299: W/Bundle(15907): Attempt to cast generated internal exception:
11-16 15:59:26.299: W/Bundle(15907): java.lang.ClassCastException: java.lang.String
11-16 15:59:26.299: W/Bundle(15907):    at android.os.Bundle.getByteArray(Bundle.java:1317)
11-16 15:59:26.299: W/Bundle(15907):    at com.facebook.android.Util.openUrl(Util.java:155)
11-16 15:59:26.299: W/Bundle(15907):    at com.facebook.android.Facebook.request(Facebook.java:563)
11-16 15:59:26.299: W/Bundle(15907):    at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
11-16 15:59:26.299: W/Bundle(15907): <!>android.os.Bundle 775<!> Key format expected byte[] but value was a java.lang.String.  The default value <null> was returned.
11-16 15:59:26.299: W/Bundle(15907): Attempt to cast generated internal exception:
11-16 15:59:26.299: W/Bundle(15907): java.lang.ClassCastException: java.lang.String
11-16 15:59:26.299: W/Bundle(15907):    at android.os.Bundle.getByteArray(Bundle.java:1317)
11-16 15:59:26.299: W/Bundle(15907):    at com.facebook.android.Util.openUrl(Util.java:155)
11-16 15:59:26.299: W/Bundle(15907):    at com.facebook.android.Facebook.request(Facebook.java:563)
11-16 15:59:26.299: W/Bundle(15907):    at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
11-16 15:59:31.009: W/Bundle(15907): <!>android.os.Bundle 775<!> Key message expected byte[] but value was a java.lang.String.  The default value <null> was returned.
11-16 15:59:31.009: W/Bundle(15907): Attempt to cast generated internal exception:
11-16 15:59:31.009: W/Bundle(15907): java.lang.ClassCastException: java.lang.String
11-16 15:59:31.009: W/Bundle(15907):    at android.os.Bundle.getByteArray(Bundle.java:1317)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.Util.encodePostBody(Util.java:63)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.Util.openUrl(Util.java:182)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.Facebook.request(Facebook.java:563)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
11-16 15:59:31.009: W/Bundle(15907): <!>android.os.Bundle 775<!> Key method expected byte[] but value was a java.lang.String.  The default value <null> was returned.
11-16 15:59:31.009: W/Bundle(15907): Attempt to cast generated internal exception:
11-16 15:59:31.009: W/Bundle(15907): java.lang.ClassCastException: java.lang.String
11-16 15:59:31.009: W/Bundle(15907):    at android.os.Bundle.getByteArray(Bundle.java:1317)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.Util.encodePostBody(Util.java:63)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.Util.openUrl(Util.java:182)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.Facebook.request(Facebook.java:563)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
11-16 15:59:31.009: W/Bundle(15907): <!>android.os.Bundle 775<!> Key access_token expected byte[] but value was a java.lang.String.  The default value <null> was returned.
11-16 15:59:31.009: W/Bundle(15907): Attempt to cast generated internal exception:
11-16 15:59:31.009: W/Bundle(15907): java.lang.ClassCastException: java.lang.String
11-16 15:59:31.009: W/Bundle(15907):    at android.os.Bundle.getByteArray(Bundle.java:1317)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.Util.encodePostBody(Util.java:63)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.Util.openUrl(Util.java:182)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.Facebook.request(Facebook.java:563)
11-16 15:59:31.009: W/Bundle(15907):    at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
11-16 15:59:31.019: W/Bundle(15907): <!>android.os.Bundle 775<!> Key format expected byte[] but value was a java.lang.String.  The default value <null> was returned.
11-16 15:59:31.019: W/Bundle(15907): Attempt to cast generated internal exception:
11-16 15:59:31.019: W/Bundle(15907): java.lang.ClassCastException: java.lang.String
11-16 15:59:31.019: W/Bundle(15907):    at android.os.Bundle.getByteArray(Bundle.java:1317)
11-16 15:59:31.019: W/Bundle(15907):    at com.facebook.android.Util.encodePostBody(Util.java:63)
11-16 15:59:31.019: W/Bundle(15907):    at com.facebook.android.Util.openUrl(Util.java:182)
11-16 15:59:31.019: W/Bundle(15907):    at com.facebook.android.Facebook.request(Facebook.java:563)
11-16 15:59:31.019: W/Bundle(15907):    at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
11-16 15:59:34.079: D/text(15907): <!>com.ozzem.mybirthday.FBWallWriterActivity$1$1 128<!> facebook post complete

这是正常的吗?

1 个答案:

答案 0 :(得分:1)

当您执行请求时,您应该传递一个byte []数组作为参数,但是您传递一个String对象作为参数,从而导致不兼容的参数传递,这会导致警告并将值设为null异常。