使用 Graph API 对 Facebook 中的帖子进行地理定位
我一直在尝试通过 Graph API 在页面上发布针对地理位置的状态更新,但到目前为止取得的成功有限。
使用 Facebook 图形 API,我已经成功地定位到国家/地区,但无法定位到城市或地区。
尝试其中任何一个:
>>> graph.put_object("me", "feed", message="Targeted at Boston", targeting={"countries": 'US', 'cities': 'boston, ma'})
>>> graph.put_object("me", "feed", message="Targeted at Boston", targeting={"countries": 'US', 'cities': ['us, boston, ma']})
>>> graph.put_object("me", "feed", message="Targeted at Boston", targeting=[{'country': 'us', 'city': 'boston', 'region': 'ma'}])
>>> graph.put_object("me", "feed", message="Targeted at Seattle", targeting={"countries": 'US', 'cities': [{'name': 'seattle, wa'}]})
>>> graph.put_object("me", "feed", message="Targeted at Seattle", targeting={"countries": 'US', 'cities': [{'name': 'seattle, wa'}]})
结果要么是公开帖子,要么是具有自定义隐私的帖子,但不针对任何特定位置。
这:
>>> graph.put_object("me", "feed", message="Targeted at Seattle", targeting={"countries": 'US'})
致力于选择性地仅针对美国。
我使用 Facebook python-sdk 来处理请求。
我一直在尝试多种方法来让定位发挥作用,但记录很少,而且 Facebook 开发者论坛上也没有太多可用信息。
有没有人能够传递用于地理定位多个目标的 json...例如波士顿、马萨诸塞州、巴黎、法国(法语),然后同时传递这两个目标?
I’ve been trying to post geolocation-targeted status updates on a Page through the Graph API, so far with limited success.
Using the Facebook graph api, I’ve been successfully able to geo-target countries, but not cities or locales.
Trying any of these:
>>> graph.put_object("me", "feed", message="Targeted at Boston", targeting={"countries": 'US', 'cities': 'boston, ma'})
>>> graph.put_object("me", "feed", message="Targeted at Boston", targeting={"countries": 'US', 'cities': ['us, boston, ma']})
>>> graph.put_object("me", "feed", message="Targeted at Boston", targeting=[{'country': 'us', 'city': 'boston', 'region': 'ma'}])
>>> graph.put_object("me", "feed", message="Targeted at Seattle", targeting={"countries": 'US', 'cities': [{'name': 'seattle, wa'}]})
>>> graph.put_object("me", "feed", message="Targeted at Seattle", targeting={"countries": 'US', 'cities': [{'name': 'seattle, wa'}]})
results in either a public post, or a post with CUSTOM privacy, but not targeted to any specific location.
This:
>>> graph.put_object("me", "feed", message="Targeted at Seattle", targeting={"countries": 'US'})
works to selectively target only the United States.
I'm using the Facebook python-sdk for the requests.
I’ve been trying multiple ways to get the targeting to work, but it’s poorly documented and there isn’t much information available on the Facebook developer forums.
Has anyone been able to pass json used to geotarget multiple targets....like Boston, MA, Paris, France (in french), and then both at the same time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是您需要城市和区域设置键,您可以在这里找到它们:
https://developers.facebook.com/docs/reference/ ads-api/get-autocomplete-data/
是的,您可以传递多个城市。
The problem is that you need the city and locale keys, which you can find here:
https://developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/
Yes, you can pass multiple cities.
区域设置示例
example for locales