0

I would like to show the latest N Facebook posts on my website.

I am using this simple code:

var FB = require('fb')

FB.api('/flourandfire/posts', 'get', { fields: [ 'message', 'picture' ], access_token: '1694494XXXXXXXX|1ba36298123bbf9689942fXXXXXXXXXX' }, 
function (res) {
  if (!res || res.error) {
    console.log(!res ? 'error occurred' : res.error)
    return
  }
  console.log(res)
})

However, I need to be able to have some kind of filtering, since there is "noise" in the feed due to the direct link with Instagram (which results in short posts with a picture, that I do NOT want to include in the website's feed)

I basically need to somehow "differentiate" specific posts, which will then placed on the site.

I could fetch 100 posts and filter myself based on a specific tag (like #pub; however, there is the risk of having lots of Instagram posts, more than 100, and end up with ZERO posts on the website.

How would you solve this issue?

Merc
  • 16,277
  • 18
  • 79
  • 122
  • see my answer. btw, please do not forget to accept my answer in your other thread, it seems that it is working for you now ;) - https://stackoverflow.com/questions/48091919/simple-facebook-api-query - although, i would not use the access token directly in the api call - better set it earlier, in case you want to do more than 1 api call. – andyrandy Jan 04 '18 at 14:38

1 Answers1

0

There is no official filtering, i would do it like this:

  1. Get N entries by setting the limit parameter to N
  2. Filter them on your own
  3. If there are less than N elements after filtering, use another API call to get more items
  4. Repeat from Number 2

Just an idea though, you could also increase the initial limit - but it would usually result in a slower API call so be careful with that.

andyrandy
  • 72,880
  • 8
  • 113
  • 130