使用Facebook Graph API创建位置 [英] Create post with location using Facebook Graph API

查看:98
本文介绍了使用Facebook Graph API创建位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用JavaScript SDK在位置(使用纬度和经度)上发布?没有找到任何一个例子来发布一个位置。

How to post on Facebook with a location(using latitude and longitude) using its JavaScript SDK? Can't find any example to post with a location.

是否需要打开图形操作来创建帖子中的位置?

Will Open Graph action creation be required for posting location in the post?

另外,是否可以共享页面的URL,而是使用页面上的Open Graph标签来分享在Facebook发布中使用的位置详细信息?

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?

使用短信创建帖子的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);
  }
});

文档中的一个例子说:

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创建位置信息?

Does this mean that a location post cannot be created using Graph API for a user's feed?

参考:

  • https://developers.facebook.com/docs/javascript/reference/FB.api
  • https://developers.facebook.com/docs/graph-api/reference/location/

已编辑:

找到一个例子来创建一个帖子,其中附加的位置被回答这里

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

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

Though the next question is, how to find location id using Latitude and Longitude?

推荐答案

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

You can find the location id by https://graph.facebook.com/search?q=karachi&type=page&access_token=YOURTOKEN This will give you the list of places which match karachi.

这篇关于使用Facebook Graph API创建位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆