我正在尝试使用Android Facebook sdk在用户的朋友的墙上发帖。我已使用类似的电话成功发布到用户自己的新闻Feed。使用我当前的代码,邮件给朋友工作没有任何障碍,除了消息是空白的。这些附件似乎都不起作用。它在朋友的墙上显示为一个完全空白的帖子。
这是我正在使用的代码:
private void publishChallengeToFriend() {
String description =
"I challenge you to " + m_challenge.getTitle() + "!" +
" I finished this challenge with a score of " + getScore() + "."
+ " Can you beat that?";
Bundle params = new Bundle();
params.putString(Facebook.TOKEN, m_facebook.getAccessToken());
params.putString("message", "");
params.putString("name", "You have been challenged!");
params.putString("caption", "Mobile Challenges");
params.putString("description", description);
try{
m_facebook.request(getFriendId() + "/feed",params, "POST");
}
catch (Exception e){
Log.d("TAG", "Facebook Error: " + e.getLocalizedMessage());
}
}
我已经授权用户,我知道这样做有效,因为我可以发布到用户自己的Feed。我知道https://github.com/facebook/facebook-android-sdk/issues/166的github问题#166。我已经尝试通过在我想传输的每个字符串上调用getBytes()来为每个附件使用putByteArray()。这仍然在朋友的墙上显示为空白帖子。
我愿意在朋友的墙上使用任何发布方法,它不一定是facebook的请求。我也使用过asyncfacebookrunner.request()并遇到了同样的问题。理想情况下,我想使用一个对话框来显示这个,但我不知道如何使用dialog()函数的朋友帖子。然而,我毫不费力地使用它进行状态更新。
谢谢!
答案 0 :(得分:3)
您将消息作为描述,尝试将其移至消息参数,“description”参数是您在帖子中放置的链接的描述,并将显示在链接下方。它不会显示在你的帖子上,因为你没有链接任何东西!你可以在下面看到我的方法:
protected void postToWall(String userID){
try {
if (isSession()) {
String response = mFacebook.request((userID == null) ? "me" : userID);
Bundle params = new Bundle();
params.putString("message", "put message here");
params.putString("link", "http://mylink.com");
params.putString("caption", "{*actor*} just posted this!");
params.putString("description", "description of my link. Click the link to find out more.");
params.putString("name", "Name of this link!");
params.putString("picture", "http://mysite.com/picture.jpg");
response = mFacebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST");
Log.d("Tests",response);
if (response == null || response.equals("") ||
response.equals("false")) {
Log.v("Error", "Blank response");
}
} else {
// no logged in, so relogin
Log.d(TAG, "sessionNOTValid, relogin");
mFacebook.authorize(this, PERMS, new LoginDialogListener());
}
}catch(Exception e){
e.printStackTrace();
}
}
这是结果,因此您可以看到帖子上显示不同参数的位置:
答案 1 :(得分:0)