简体   繁体   中英

How to get facebook posts from last week in php

I need to get all my facebook posts (field "message" and "date") from specific time period in example last week.

I need them in php variable.

Can You help me?

This give me only last 25:

$pageFeed = $facebook->api('1750433298/feed');
       print_r($pageFeed);

API returns JSON object, which consists of "data" array (your messages) and "paging". "Paging has 2 fields, "previous" and "next". In order to get more of your messages you need to follow the link, given in "next" field.

$pageFeed = $facebook->api('1750433298/feed');
$next = $pageFeed["paging"]["next"]; //contains link to set of next 25 messages
$exp = explode("until=",$next);
$until = $exp[1]; // timestamp of last message in next set
$nextPage = $facebook->api('1750433298/feed', "GET", array(
'limit' => 25,
'until' => $until
));

Try this:

1750433298/feed?since=2012-12-31&until=2013-01-06&limit=200

You may still not get all your posts. Feed has some tight limits, so you may need to execute multiple queries via the pagination links to get them all.

If you need more control of what gets returned, look at querying the stream table with FQL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM