سؤال

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?

هل كانت مفيدة؟

المحلول

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

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 مع الإسناد
لا تنتمي إلى StackOverflow
scroll top