How to specify location targeting of FB post via Graph API

时光总嘲笑我的痴心妄想 提交于 2020-01-02 08:55:18

问题


Some time ago there was a field called targeting in the Post API Reference but now it's gone and I don't know how to add a specific location and language targeting to the post via API. I've search a lot: some results refer to the targeting parameter. I've tried it, but it seems don't working.

I've tried 2 ways to achieve this, but without any success:

$post_details = array('message' => $msg, 'privary' => array('value' => 'CUSTOM', 'description' => array('country' => 'Germany')));
$fb->api('/PAGE_ID/feed', 'POST', $post_details);

and

$post_details = array('message' => $msg, 'targeting' => array('country' => 'Germany'));
$fb->api('/PAGE_ID/feed', 'POST', $post_details);

Please help me understand how can I achieve this?


回答1:


for targeting, see the privacy property of the post object: https://developers.facebook.com/docs/reference/api/post/

The description field may contain a comma-separated lists of valid country, city and language if a Page's post targeting by location/language is specified.

Note: This privacy setting only applies to posts to the current or specified user's own Wall. Facebook ignores this setting for targeted Wall posts (when the user is writing on the Wall of a friend, Page, event, group connected to the user). Consistent with behavior on Facebook, all targeted posts are viewable by anyone who can see the target's Wall.




回答2:


instead of privacy you also can use feed_targeting

All parameters which you can target like languages,cities,counties are facebook specific. You can resolve them via autocomplete data :

"{'locales':[1001],'countries':[GE],'cities':[825886]}"

Nice feature for automatic posting with targeting but so bad documented in the Facebook documentation...




回答3:


To make this easier this is the bit you need http://developers.facebook.com/docs/reference/api/page/#targeting

this will give the info on how to target cities too. http://developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/

a more complete solution from me on this question Geotargeting Page Posts with the Facebook API



来源:https://stackoverflow.com/questions/8629610/how-to-specify-location-targeting-of-fb-post-via-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!