'How to exclude tagged posts from Facebook Graph API response

I'm using v 2.8 of the Facebook Graph API, and am trying to get a list of all posts from a Facebook page, but excluding all mentions of the page from random public posts. I have thousands of Facebook pages and millions of mentions, so it's important to drop the tagged posts if possible.

I've tried the following:

{page-id}/feed -> Provides All Posts Where Page is Tagged, Posts by Admin, and Posts by Users on Page

{page-id}/promotable_posts -> Returns All the Dark Posts (but no posts from users on page)

/{page-id}/tagged -> shows all public posts in which the page has been tagged (opposite of what I want)

Summary: Is there any way to get all posts by users (not by a Page Admin) on a page itself (not just public mentions of that page).



Solution 1:[1]

So, trying to research, I understood that we can make filtering on our side:

  1. Get facebook feed
const response = await axios(`https://graph.facebook.com/v2.0/${pageId}/feed`, {
            params: {
                limit,
                access_token: token,
                fields: [
                    'id',
                    'created_time',
                    'message',
                    'from', // <-- this field is requred for filtering
                    'full_picture',
                    'permalink_url',
                ].join(','),
            },
        });
        return response.data.data;
  1. Manually filter posts not from root page
    const posts = await getFacebookFeed({ pageId: FACEBOOK_PAGE_ID, token: FACEBOOK_TOKEN, limit: 20 })
        .then(posts => {
            logger.info(`Loaded ${posts.length} items`);
            // Ignore tagged posts
            return posts.filter(({ from }) => from.id === FACEBOOK_PAGE_ID);
        });
    logger.info(`After filtering left ${posts.length} items`);

Read more about feed [here][1]

[1]: https://developers.facebook.com/docs/graph-api/reference/v13.0/page/feed)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bohdan Yurchuk