Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get ALL Facebook posts using facebook api and paging

It's my intention to get all past posts. I have created a Facebook app. When this code is executed, I have properly logged in with the correct appid and secret.

function loadPage() {   // calls the first batch of records
   FB.api("/me/feed",{},function(response) { procBatch(response) } );
   }

function procBatch(dat) { // handle this batch, request the next batch
   for ( i = 0; i < dat.data.length; i++ ) {
      procRow(dat.data[i]);  // process this row
      }
   if ( typeof(dat.paging) != 'undefined' ) {
      FB.api(dat.paging.next, {}, function(response){ procBatch(dat); } );
      } else {
      alert("No more records expected");
      }
   }

Unfortunately, this only takes me back about six months.

Is it possible to go back further?

Thanks in advance.

like image 667
user2943007 Avatar asked May 06 '26 19:05

user2943007


1 Answers

Yes, that's possible.

This can be done by increasing the limit of number object per page. I've not tried retrieving ALL the posts, but I am pretty sure that you can easily retrieve posts which are even few years old.

You can call /me/feed?limit=numberOfObjectsPerPage instead of just /me/feed to increase this limit.

You can find more information on this here. Do have a look at the Time Based Pagination on the link. This will explain you how to manage the output for the feeds.

like image 68
Rahil Arora Avatar answered May 11 '26 16:05

Rahil Arora



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!