开发者

Issue with Facebook request in Android

I'm using facebook-android-sdk to post messages to my wall.

The following request:

Bundle params = new Bundle();

params.putString("message", "test message");

mAsyncRunner = new AsyncFacebookRunner(mFacebook);
mAsyncRunner.request("me/feed", params, "POST", new PostRequestListener(), null);  

returns the warnings shown below, although the message is shown correctly on the wall.

When converting the message to bytes, as seen in similar questions on Stackoverflow:

params.putByteArray("message", "test message".Bytes());

there is no more warnings for Key message, and the post is shown on the Facebook wall, but with no message.

What's wrong?

Thanks.

Warnings:

03-14 11:35:01.635: WARN/Bundle(9963): Key message expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-14 11:35:01.675: WARN/Bundle(9963): Attempt to cast generated internal exception:
03-14 11:35:01.675: WARN/Bundle(9963): java.lang.ClassCastException: java.lang.String
03-14 11:35:01.675: WARN/Bundle(9963):     at android.os.Bundle.getByteArray(Bundle.java:1305)
03-14 11:35:01.675: WARN/Bundle(9963):     at com.facebook.android.Util.encodePostBody(Util.java:63)
03-14 11:35:01.675: WARN/Bundle(9963):     at com.facebook.android.Util.openUrl(Util.java:182)
03-14 11:35:01.675: WARN/Bundle(9963):     at com.facebook.android.Facebook.request(Facebook.java:559)
03-14 11:35:01.675: WARN/Bundle(9963):     at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
03-14 11:35:01.685: WARN/Bundle(9963): Key method expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-14 11:35:01.725:开发者_如何学Go WARN/Bundle(9963): Attempt to cast generated internal exception:
03-14 11:35:01.725: WARN/Bundle(9963): java.lang.ClassCastException: java.lang.String
03-14 11:35:01.725: WARN/Bundle(9963):     at android.os.Bundle.getByteArray(Bundle.java:1305)
03-14 11:35:01.725: WARN/Bundle(9963):     at com.facebook.android.Util.encodePostBody(Util.java:63)
03-14 11:35:01.725: WARN/Bundle(9963):     at com.facebook.android.Util.openUrl(Util.java:182)
03-14 11:35:01.725: WARN/Bundle(9963):     at com.facebook.android.Facebook.request(Facebook.java:559)
03-14 11:35:01.725: WARN/Bundle(9963):     at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
03-14 11:35:01.735: WARN/Bundle(9963): Key access_token expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-14 11:35:01.775: WARN/Bundle(9963): Attempt to cast generated internal exception:
03-14 11:35:01.775: WARN/Bundle(9963): java.lang.ClassCastException: java.lang.String
03-14 11:35:01.775: WARN/Bundle(9963):     at android.os.Bundle.getByteArray(Bundle.java:1305)
03-14 11:35:01.775: WARN/Bundle(9963):     at com.facebook.android.Util.encodePostBody(Util.java:63)
03-14 11:35:01.775: WARN/Bundle(9963):     at com.facebook.android.Util.openUrl(Util.java:182)
03-14 11:35:01.775: WARN/Bundle(9963):     at com.facebook.android.Facebook.request(Facebook.java:559)
03-14 11:35:01.775: WARN/Bundle(9963):     at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
03-14 11:35:01.785: WARN/Bundle(9963): Key format expected byte[] but value was a java.lang.String.  The default value <null> was returned.
03-14 11:35:01.825: WARN/Bundle(9963): Attempt to cast generated internal exception:
03-14 11:35:01.825: WARN/Bundle(9963): java.lang.ClassCastException: java.lang.String
03-14 11:35:01.825: WARN/Bundle(9963):     at android.os.Bundle.getByteArray(Bundle.java:1305)
03-14 11:35:01.825: WARN/Bundle(9963):     at com.facebook.android.Util.encodePostBody(Util.java:63)
03-14 11:35:01.825: WARN/Bundle(9963):     at com.facebook.android.Util.openUrl(Util.java:182)
03-14 11:35:01.825: WARN/Bundle(9963):     at com.facebook.android.Facebook.request(Facebook.java:559)
03-14 11:35:01.825: WARN/Bundle(9963):     at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)


It's a bug in facebook's SDK, see this answer for a fix.


Same question check it out Facebook Post

Okay try this way to post on wall

Bundle parameters = new Bundle();
parameters.putString("method", "stream.publish");
parameters.putString("attachment",
"{\"name\":\""
+ b.getString("title")
+ "\",\"description\":\""
+ desc
+ "\"}]}");
    authenticatedFacebook.dialog(DealCities_View.this, "stream.publish",
                                    parameters, new TestUiServerListener());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜