简体   繁体   English

使用Facebook Graph API创建位置信息

[英]Create post with location using Facebook Graph API

How to post on Facebook with a location(using latitude and longitude) using its JavaScript SDK? 如何使用JavaScript SDK在Facebook上发布位置(使用纬度和经度)? Can't find any example to post with a location. 找不到任何带位置的帖子示例。

Will Open Graph action creation be required for posting location in the post? 在帖子中发布位置是否需要Open Graph动作创建?

Also, is it possible to share the url of a page and instead make use of Open Graph tags on the page to share the location details for use in Facebook post? 此外,是否可以共享页面的URL,而是使用页面上的Open Graph标签来共享位置详细信息以便在Facebook帖子中使用?

JavaScript code to create post with just text message: 使用短信创建帖子的JavaScript代码:

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);
  }
});

An example in the documentation says: 文档中的一个例子说:

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.

Does this mean that a location post cannot be created using Graph API for a user's feed? 这是否意味着无法使用Graph API为用户的Feed创建位置信息?

Reference: 参考:

Edited: 编辑:

Able to find an example to create a post with location attached as answered here : 能找到一个例子来创建一个附带的回答位置后在这里

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

Though the next question is, how to find location id using Latitude and Longitude? 虽然下一个问题是,如何使用纬度和经度查找位置ID?

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

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

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