Search code examples
phpfacebookfacebook-graph-apilocationtargeting

How to specify location targeting of FB post via Graph API


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?


Solution

  • 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.