Android “如何区分”;标签";及;贴在墙上;facebook API中的操作

Android “如何区分”;标签";及;贴在墙上;facebook API中的操作,android,facebook,facebook-graph-api,Android,Facebook,Facebook Graph Api,我正在写一个facebook应用程序。但我有一个问题,“标记”和“在其他墙上张贴”操作都有相同的格式 例如,如果A在B的墙上张贴: "from": { "name": "A", "id": "123456" }, "to": { "data": [ { "name": "B", "id": "123456789" }

我正在写一个facebook应用程序。但我有一个问题,“标记”和“在其他墙上张贴”操作都有相同的格式

例如,如果A在B的墙上张贴:

"from": {
        "name": "A",
        "id": "123456"
     },
     "to": {
        "data": [
           {
              "name": "B",
              "id": "123456789"
           }  
        ]
     },
如果A标记了B,结果是一样的


我如何区分它们呢?

注意那些只存在于墙柱上而不存在于标记柱上的“动作”。

我今天为此挣扎了一段时间。我最后做的是检查“To”数组中的第一个用户是否也包含在“message_tags”对象中。如果收件人用户也是带标签的用户,则当前帖子只是一个“标签”,而不是您所说的“其他墙上的帖子”

以下是我在应用程序中执行此操作的(凌乱)代码:

                JSONObject recipientData = story.getJSONObject("to");
                JSONArray recipientArray = recipientData.getJSONArray("data");
                JSONObject recipient = recipientArray.getJSONObject(0);
                recipientName = recipient.getString("name");
                String recipientId = recipient.getString("id");

                // if the post's recipient is also a tagged user, then this is not a post to
                // another user's wall, but rather a status update. Leave the recipient blank then.
                if(story.has("message_tags")){
                    JSONObject tags = story.getJSONObject("message_tags");
                    for(int tagIdx = 0; tagIdx < tags.names().length() ; tagIdx++){
                        JSONArray tagArray = tags.getJSONArray(tags.names().getString(tagIdx));
                        String tagId = tagArray.getJSONObject(0).getString("id");
                        if(tagId.equals(recipientId)){
                            recipientName = "";
                            break;
                        }
                    }
                }
JSONObject recipientData=story.getJSONObject(“to”);
JSONArray recipientArray=recipientData.getJSONArray(“数据”);
JSONObject recipient=recipientArray.getJSONObject(0);
recipientName=recipient.getString(“名称”);
String recipientId=recipient.getString(“id”);
//如果帖子的收件人也是一个标记用户,那么这不是一篇要发布的帖子
//另一个用户的墙,而是一个状态更新。然后将收件人留空。
if(story.has(“消息标签”)){
JSONObject tags=story.getJSONObject(“消息标签”);
对于(int-tagIdx=0;tagIdx
出于显示目的,如果帖子实际上只是带有标记用户的状态更新,我将帖子的recipientName设置为空字符串。recipientName仅在这是“其他墙上的帖子”时设置


希望这对某人有所帮助,我知道这是一个老问题。

A嵌套在“发件人”中,B嵌套在“至”>“数据”中。这是图形API的默认格式,创建消息的人嵌套在发件人中,接收消息的人嵌套在“至”>“数据”中。我不能基于它来解决这个问题。但是,谢谢你的意见:)它不起作用@Vikas:)。因为如果我在我的帖子上贴上这样的标签,“action”将会出现,或者我的朋友给我的朋友贴上标签,都是一样的:)谢谢@mattgmg1990。这个问题我贴了这么久,现在我不记得它到底是什么了。为你的挣扎投上一票:):)我在将近三年前发布了这条消息,所以我几乎记不起来了,但谢谢你!