使用 Graph API 对 Facebook 中的帖子进行地理定位

发布于 2024-12-20 14:03:36 字数 1379 浏览 1 评论 0原文

我一直在尝试通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尽揽少女心 2024-12-27 14:03:36

问题是您需要城市和区域设置键,您可以在这里找到它们:
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.

想念有你 2024-12-27 14:03:36

区域设置示例

curl -F 'access_token=[page_access_token]' 
     -F 'message=Testing post to certain language' 
     -F 'link=http://stackoverflow.com/questions/15280604/can-you-gate-and-target-a-page-post-through-the-facebook-graph-api' 
     -F 'feed_targeting={'locales':[1001]}' 
https://graph.facebook.com/[pageID]/feed

example for locales

curl -F 'access_token=[page_access_token]' 
     -F 'message=Testing post to certain language' 
     -F 'link=http://stackoverflow.com/questions/15280604/can-you-gate-and-target-a-page-post-through-the-facebook-graph-api' 
     -F 'feed_targeting={'locales':[1001]}' 
https://graph.facebook.com/[pageID]/feed
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文