使用Graph API在Facebook中进行地理定位帖子
我一直在尝试通过Graph API在一个页面上发布带有地理位置的状态更新,但到目前为止效果不太理想。
使用Facebook的Graph 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,以便同时针对多个地点……比如波士顿,马萨诸塞州,法国巴黎(用法语),然后同时发布这两个地点的内容?
2 个回答
0
地区设置的示例
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
1
问题是你需要城市和地区的关键字,你可以在这里找到它们:https://developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/
没错,你可以传递多个城市。