简体   繁体   English

通过Facebook API将消息发布到别人的墙(朋友的墙上)?

[英]Post message to someone else's wall (friend's wall) via Facebook API?

Does Facebook allow that user A using mobile app posts something (text, image or URL) on user B's wall? Facebook是否允许使用移动应用的用户A用户B的墙上发布某些内容(文本,图片或网址)?

I have been searching for this for a couple of days, but I cannot find anything about it in Facebook API docs. 我已经搜索了几天,但我在Facebook API文档中找不到任何相关内容。

To make it clear, I do not need to post something on my own wall, but on my friend's wall using Facebook API. 为了说清楚,我不需要在自己的墙上发布一些内容,而是使用Facebook API在我朋友的墙上发布。

Am I right saying that this is not possible/allowed at this moment? 我说得对,这是不可能的/允许的吗?

Use this piece of code to post on another user's wall. 使用这段代码在另一个用户的墙上发布。

Bundle postStatusMessage = new Bundle();

// ADD THE STATUS MESSAGE TO THE BUNDLE
postStatusMessage.putString("message", finalStatusMessage);

Utility.mAsyncRunner.request(userID + "/feed", postStatusMessage, "POST", new StatusUpdateListener(), null);

You can also upload a photo with the above code, like this: 您还可以使用上面的代码上传照片 ,如下所示:

byte[] data = null;

ByteArrayOutputStream baos = new ByteArrayOutputStream();
Bitmap bmpImageCamera.compress(CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();

Bundle postImgGallery = new Bundle();

// ADD THE PHOTO DATA TO THE BUNDLE
postImgGallery.putByteArray("photo", data);

And then use this to check the result. 然后用它来检查结果。

private class StatusUpdateListener extends BaseRequestListener  {

    @Override
    public void onComplete(String response, Object state) {

    }

    @Override
    public void onFacebookError(FacebookError e, Object state) {

    }

}

If successfully posted, String response in the onComplete() will give you an ID for the post. 如果成功发布,onComplete()中的String response将为您提供帖子的ID。

NOTE 1: The above code uses the older Facebook SDK (Pre v 3.x) so you will have to adapt the code to work with the new SDK if you are using it. 注意1:上面的代码使用较旧的Facebook SDK(Pre v 3.x),因此如果您使用它,则必须调整代码以使用新SDK。 It will need a few minor changes. 它需要一些小的改动。

NOTE 2: Facebook has planned to stop the ability to let applications post to other users walls. 注2: Facebook计划停止让应用程序发布到其他用户墙的能力。 Source: https://developers.facebook.com/blog/post/2012/10/10/platform-updates--operation-developer-love/ . 资料来源: https//developers.facebook.com/blog/post/2012/10/10/platform-updates--operation-developer-love/ Going forward, you will need to use the feed dialog option. 展望未来,您需要使用Feed对话框选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM