本文介绍了Facebook 发布到 Android 上的墙,仅限消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码似乎只发布了消息",没有别的.有什么我想念的吗?(使用 Facebook Android SDK)

The below code only seems to POST the 'message' and nothing else. Is there something I am missing? (using the Facebook Android SDK)

parameters.putString("link", link);
parameters.putString("description", description);
parameters.putString("caption", caption);
parameters.putString("name", name);
parameters.putString("message", msg);

try {
    String response = mFacebook.request("me/feed", parameters, "POST");
} catch (IOException e) {
    Log.e("Error", e.toString());
}

我收到了很多警告,但已阅读这是正常的(此外,我收到了消息"警告,但仍然发布:

I am getting lots of warnings but have read this is normal (also, I am getting a warning for 'message' but that still posts:

Key caption expected byte[] but value was a java.lang.String.  The default value <null> was returned.
Attempt to cast generated internal exception:
java.lang.ClassCastException: java.lang.String

推荐答案

检查我编辑的答案,它会张贴在用户的墙上:

Check my edited answer, it will post on the user's wall:

它会显示异常情况,但不要管它,你的帖子会成功.

It will show the exception case, but don't bother about it, your post will be succeed.

public void postOnWall() {
    try{
        Bundle parameters = new Bundle();
        parameters.putString("message", "Text is lame. Listen up:");
        parameters.putString("name", "Name");
        parameters.putString("link", "http://www.google.com");
        parameters.putString("caption", "Caption");
        parameters.putString("description", "Description");

        String  response = facebook.request("me/feed",parameters,"POST");
        Log.v("response", response);
    }
    catch(Exception e){}
}

这篇关于Facebook 发布到 Android 上的墙,仅限消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 20:47