简体   繁体   English

使用Graph API在Facebook中使用Geo Targeting Posts

[英]Geo Targeting Posts in Facebook using Graph API

I've been trying to post geolocation-targeted status updates on a Page through the Graph API, so far with limited success. 我一直试图通过Graph API在页面上发布地理定位目标状态更新,到目前为止成效有限。

Using the Facebook graph api, I've been successfully able to geo-target countries, but not cities or locales. 使用Facebook图表api,我已经成功地能够对国家进行地理定位,但不是城市或地区。

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. 导致公共帖子或具有CUSTOM隐私的帖子,但不针对任何特定位置。

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. 我正在使用Facebook python-sdk来处理请求。

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. 我一直在尝试多种方法来使目标工作,但它的文档记录很差,Facebook开发者论坛上没有太多可用的信息。

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? 有没有人能够通过json用于地理定位多个目标....如波士顿,马萨诸塞州,巴黎,法国(法语),然后两者同时?

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/ 问题是您需要城市和区域设置密钥,您可以在此处找到: https//developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/

Yes, you can pass multiple cities. 是的,你可以通过多个城市。

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

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

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