首页 文章

使用Facebook Graph API创建位置信息

提问于
浏览
1

如何使用JavaScript SDK在Facebook上发布位置(使用纬度和经度)?找不到任何带位置的帖子示例 .

在帖子中发布位置是否需要Open Graph动作创建?

此外,是否可以共享页面的URL,而是使用页面上的Open Graph标签来共享位置详细信息以便在Facebook帖子中使用?

JavaScript code to create post with just text message:

var body = 'Reading JS SDK documentation';
FB.api('/me/feed', 'post', { message: body }, function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Post ID: ' + response.id);
  }
});

文档中的一个例子说:

You can make a POST request to locations edge from the following paths:
/{page_id}/locations

When posting to this edge, a Location will be created.

这是否意味着无法使用Graph API为用户的Feed创建位置信息?

参考:

编辑:

能够找到一个示例来创建一个帖子,其位置附加为已回答here

FB.api('/me/feed', 'post', {
    name: 'SomeName',
    message: 'SomeMessage',
    place: '106039436102339' // ID for Tallinn, Estonia
}, function (response) {});

虽然下一个问题是,如何使用纬度和经度查找位置ID?

1 回答

  • 0

    您可以通过 https://graph.facebook.com/search?q=karachi&type=page&access_token=YOURTOKEN 找到位置ID . 这将为您提供与卡拉奇相匹配的地点列表 .

相关问题