【问题标题】:tag friend on a Post在帖子上标记朋友
【发布时间】:2011-12-21 09:56:14
【问题描述】:

您好,我正在尝试使用官方图形 API 在墙上的帖子中标记朋友。 根据文档报告

message_tags

消息中标记的对象(用户、页面等)(需要 access_token)

包含字段的对象,其名称是消息字段中提及对象的索引;每个字段依次是 包含具有 id、name、offset 和 length 字段的对象的数组, 其中length是消息字段中对象的长度 提到

var array = {'data':{'id':XXXXXXXXXX, 'name':'Friend name','offset':0,'length':11}};
        
Facebook.code.WallPost({
    "access_token" : Titanium.App.Properties.getString('access_token'),
    "message" : $("#post_message").val(),
    "message_tags" : array
});

Facebook.code.WallPost 是一个用于发布的自定义 JavaScript 函数。

WallPost : function(data) {
    $.ajax({
      type : "POST",
      dataType : "json",
      url : "https://graph.facebook.com/me/feed",
      data : data,
      success : function(data) {
        alert("posted");
      },
      error : function(data) {
        alert("not posted");
      }
  });
}

我的代码帖子已发布但没有标签! 有人可以帮助我吗? 谢谢你,斯特凡诺

【问题讨论】:

    标签: tags tagging facebook-wall


    【解决方案1】:

    story_tags 字段包含有关故事中标记的人员和页面的信息,其格式与 Post 对象上现有的 message_tags 字段的格式完全相同。例如:

    {
     . . .
          "story": "Dhiren Patel likes Marmot.",
          "story_tags": {
            "19": [
              {
                "id": 101961456910,
                "name": "Marmot",
                "offset": 19,
                "length": 6
              }
            ],
            "0": [
              {
                "id": 1207059,
                "name": "Dhiren Patel",
                "offset": 0,
                "length": 12
              }
            ]
          }, 
     . . .
    }
    

    story_tags 字段中的每个标签按其偏移量索引到故事字段中引用对象的位置。

    更多信息:https://developers.facebook.com/blog/post/592/

    【讨论】:

    • 您好,eseceve,我尝试使用"message_tags" : { "0" : [{ "id" : XXXXXXXXX, "name" : "Name and Surname", "offset" : 0, "length" : 16 }] } 发布消息,但用户标签未出现在 facebook 网站上
    • 嗨@stefanodiluca 该错误于11月22日报告。订阅以了解何时修复。 link
    【解决方案2】:

    它是一个只读对象。试试看:

       FB.api('/me/posts', { limit: 3 }, function(response) {
      for (var i=0, l=response.length; i<l; i++) {
        var post = response[i];
        if (post.message) {
          alert('Message: ' + post.message);
        } else if (post.attachment && post.attachment.name) {
          alert('Attachment: ' + post.attachment.name);
        }
      }
    });
    

    并设置断点并读取响应对象,它包含message_tags。

    /J

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多