0

Is it possible to pass a targeting query to the graph api when requesting facebook posts? If so, how should this be done ?

I found this question:

How to specify location targeting of FB post via Graph API

And this one

Geotargeting Page Posts with the Facebook API

But it doesn't seem to work, I've been trying the following in the graph explorer. And a lot more permutations as well.

PAGE_ID/posts?fields=targeting({'countries' : ['DE'] })
PAGE_ID/posts?fields=targeting("{'countries' : ['DE'] }")
PAGE_ID/posts?targeting={'countries' : ['DE'] }
PAGE_ID/posts?targeting={countries : ['DE'] }
PAGE_ID/posts?targeting="{'countries' : ['DE'] }"
PAGE_ID/posts?targeting="{countries : ['DE'] }"

With all these queries I keep just getting non filtered results or errors.

Is there a correct way to do it, and is there maybe any documentation anywhere ?

Community
  • 1
  • 1
Willem D'Haeseleer
  • 19,661
  • 9
  • 66
  • 99

1 Answers1

0

You cannot use query qualifications like you posted witht he Graph API in general. The targeting and feed_targeting fields are set upon the publishing of Posts (https://developers.facebook.com/docs/graph-api/reference/page/feed#pubfields).

What you could try is using the FQL stream table to get the posts with a certain targeting:

select post_id from stream where source_id={page_id} and feed_targeting.country in ('DE')

Be sure to notice the access restrictions:

To read the stream table you need read_stream permissions for all posts that the current session user is able to view, read_insights permissions to see post impressions for any posts made by a Page owned by the current session user.

Tobi
  • 31,405
  • 8
  • 58
  • 90