简体   繁体   中英

facebook graph api userpost fetching

I am using facebook graph api to fetch the user posts using php.I need to get the user posts from a start data. So i used the since parameter in the URL. this is my code for the above condition:

$url ="https://graph.facebook.com/FB_ID/feed?since=1%20june%202016&limit=25&access_token=ACCESS_TOCKEN";
$result = file_get_contents($url,0,null,null);

But this is returns an empty result. So i have tired with CURL.

$url = "https://graph.facebook.com/FB_ID/feed?since=1%20june%202016&limit=25&access_token=ACCESS_TOCKEN";
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_URL,$url);
$result = curl_exec($ch);
curl_close($ch);

But both this attempts are getting empty/error messages. If we tried the URL without the since parameter, it's working fine.

$url = "https://graph.facebook.com/FB_ID/feed?limit=25&access_token=ACCESS_TOCKEN";
$result = file_get_contents($url,0,null,null);

If anyone can help on this?

You'll need to format it as a time_range object.

https://graph.facebook.com/FB_ID/feed?time_range={'since':YYYY-MM-DD,'until':YYYY-MM-DD}&limit=25&access_token=ACCESS_TOCKEN

OR

Try with since and until (Both)

https://graph.facebook.com/FB_ID/feed?since=2011-07-01&until=2012-08-08&limit=25&access_token=ACCESS_TOCKEN

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