如何在安卓手机上发布信息到Facebook好友的墙上

7

可能是重复问题:
如何在Android上发布朋友圈?

我做了一个应用程序,在其中获取了我所有Facebook朋友的列表,现在我想要点击任何一个朋友行时,我就能够在他/她的朋友圈上发布。

那么我需要给出哪些权限以及需要编写什么样的代码才能实现这一功能呢?

例如:我已经给出了以下权限并编写了以下onListItemClick代码:

权限:

         mFacebook.authorize(main, new String[] { "publish_stream",
        "friends_birthday", "friends_photos"  }, new MyAuthorizeListener());

代码:

  @Override

   protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    MyFriend friend = (MyFriend) this.getListAdapter().getItem(position);

}

我正在获取FbId、姓名、生日和图片

 public class MyFriend {
private String fbID = " ";
private String name = " ";
private String bday = " "; 
private String pic = " ";

}
2个回答

12

从现在开始,您将无法在我们朋友的墙上发布内容。

因为Facebook已经从其Graph Api中删除了该功能,所以我们不能在朋友的墙上发布内容

这就是为什么我们只能在自己的Facebook墙上发布内容。


你们有关于不支持使用图形API“在好友的墙上发布”功能的官方声明吗? - Somnath Muluk
@SomnathMuluk 没有兄弟,但所有其他代码都无法工作... - SilentKiller
这是官方声明:https://developers.facebook.com/blog/post/2012/10/10/platform-updates--operation-developer-love/ - Deepak

3

发布朋友动态的功能已从Facebook SDK中移除。

之前,可以通过以下代码实现,如此帖子所述,

 try{
    Bundle parameters = new Bundle();
    JSONObject attachment = new JSONObject();

    try {
        attachment.put("message", "Messages");
        attachment.put("name", "Get utellit to send messages like this!");
        attachment.put("href", link);
    } catch (JSONException e) {
    }
    parameters.putString("attachment", attachment.toString());
    parameters.putString("message", "Text is lame. Listen up:");
    parameters.putString("target_id", "XXXXX"); // target Id in which you need to Post 
    parameters.putString("method", "stream.publish");
    String  response = authenticatedFacebook.request(parameters);       
    Log.v("response", response);
}
catch(Exception e){}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接