Android 中的 Facebook 请求问题
我正在使用 facebook-android-sdk 将消息发布到我的墙上。
以下请求:
Bundle params = new Bundle();
params.putString("message", "test message");
mAsyncRunner = new AsyncFacebookRunner(mFacebook);
mAsyncRunner.request("me/feed", params, "POST", new PostRequestListener(), null);
返回如下所示的警告,尽管该消息正确显示在墙上。
将消息转换为字节时,如 Stackoverflow 上的类似问题所示:
params.putByteArray("message", "test message".Bytes());
不再有 Key 消息的警告,帖子显示在 Facebook 墙上,但没有消息。
怎么了?
谢谢。
警告:
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: 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)
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: 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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是 facebook SDK 中的一个错误,请参阅此答案进行修复。
It's a bug in facebook's SDK, see this answer for a fix.
同样的问题请查看 Facebook 帖子
好的,尝试用这种方式张贴在墙上
Same question check it out Facebook Post
Okay try this way to post on wall