Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you gate and target a page post through the facebook graph api?

Enabling post privacy gating in the Page's privacy settings allows creating of posts with separate Gating and Targeting. Enable:

Post:

Now I have been able to get news feed targeting to work through the api by specifying the param feed_targeting when as specified in the docs.

However there is only one mention of Gating in the docs:

Gating vs. Targeting

Gating a post is restricted to only language and country currently. This is different from news feed targeting because a gated post to a language or country will not show up to a user outside of the gating criteria. Using targeting, the post will be visible on the Page and only visible to those in the targeting segment of the Page. If a user shares a post, the user’s friends will be able to see the post even if they are outside the targeting set.

Is is possible to set Gating through the API?

like image 751
Doug Tabuchi Avatar asked Mar 07 '13 20:03

Doug Tabuchi


People also ask

What data can I get from Facebook Graph API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

Is Facebook Graph API deprecated?

Applies to all versions. Facebook Analytics will no longer be available after June 30, 2021. Additionally, we are deprecating the App Dashboard Plugin for Marketing API. For more information visit the Business Help Center.

How do I use Facebook Graph API and extract data?

To use the Graph API Explorer tool, go to developers.facebook.com/tools/explorer. Generate the access token you need to extract data from the Facebook Graph API by selecting Get User Access Token from the App Token drop-down menu under the name of your app.

How do I get Facebook Page Insights on graph API?

You can access Page Insights by typing /insights after the name of your page in the URL field. This command will retrieve all of the Insights associated with your Page. Type "/insights" after your company name. Click the Submit button.


2 Answers

IT IS POSSIBLE!

  1. Make sure that gating is turned on for the page gate

  2. Make sure that you use the page token not the user token.

  3. Then when you create you're post with the api the targeting param will perform gating while the feed_targeting param will do news feed targeting.

Note: Gating only works for language and country.

like image 72
Doug Tabuchi Avatar answered Nov 13 '22 01:11

Doug Tabuchi


Can somebody post a bit of example code for locales and countries? There is really nothing in the api and the net overall although this feature is so powerful!

Code example that worked for me:

    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

To get language numbers:

    curl -G -d "access_token=xx" -d"q=en"  
            -d "type=adlocale" 
    https://graph.facebook.com/search

A bit of help is the Targeting from the ads api doc but only some fields are possible for post targeting.

To get locales,city,... codes graph search via curl

Hope this helps someone!

like image 43
prototyp Avatar answered Nov 12 '22 23:11

prototyp