python - 使用 Graph API 在 Facebook 中定位帖子的地理定位

标签 python facebook json geotargetting

我一直在尝试通过 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...例如波士顿、马萨诸塞州、巴黎、法国(法语),然后同时传递这两个目标?

最佳答案

问题是您需要城市和区域设置键,您可以在这里找到它们: https://developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/

是的,你可以通过多个城市。

关于python - 使用 Graph API 在 Facebook 中定位帖子的地理定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8431868/

相关文章:

Python PIP 和不安全平台警告

python - 配置不当 : The SECRET_KEY setting must not be empty error after editing django auth pipeline

ios - 从 applinkshost 创建的 Facebook AppLink

java - AppEventsLogger.activateApp(this) - 崩溃应用程序

javascript - 在未命名的 json 数组 url 中检索值

python - 自定义 unique_together 键名

python - 如何设置QMenu撕下窗口标题?

python - 寻找数据框中出现的差异

javascript - 在 jQuery 中将 JSON 数据传递给 .getJSON?

python - 如何使用python批量发布到elasticsearch?