简体   繁体   English

Facebook Graph API获取从x post开始的帖子(PHP SDK)

[英]Facebook Graph api get Posts starting from x post (PHP SDK)

Hello i've serched a lot without find an answer to this. 您好,我已经忙了很多,却找不到答案。 is possible to retrieve Fb posts of a certain public page starting from a post id?(for example tomorrow start collecting posts from the last post of today) Let's take for example Bill Gates page 是否可以从帖子ID开始检索某个公共页面的Fb帖子?(例如,明天从今天的最后一个帖子开始收集帖子)让我们以比尔·盖茨页面为例

the idea would be to do something similar to: 这个想法是做类似的事情:

$id = 216311481960; //Bill's fb id
$last_post = 10153219939326961 // last bill posts   
try {
        $request= $id.'/posts?since='.$last_post.'&access_token=xxxxxxxxxxxxxxxxxxxx|xxxxxxxxxxxxxxx-xxxxxx';
        $search = $fb->get($request);
        if (isset($search)){
            //do something
            }
    }           
catch(Exception $e) {
        echo 'Message: ' .$e->getMessage()."<h1>".$id."</h1>";
}

obviously since parameter has to be a date and that code wont work. 显然,因为参数必须是日期,并且该代码无法正常工作。 Any Idea? 任何想法? Thanks in advance. 提前致谢。 Edit 编辑

i try to search for all posts of a specific Facebook user starting not at a certain date but from a certain post, lets say that today i grab users postid1,postid2,postid3 (postid3 is the last post i've taken, and i save that id) next time i would to grab new posts published after postid3 (since postid3) 我尝试搜索不是从某个日期开始而是从某个帖子开始的特定Facebook用户的所有帖子,可以说今天我抓住了用户postid1,postid2,postid3(postid3是我拍摄的最后一篇帖子,并且我保存了该id)下次我要获取postid3之后发布的新帖子(因为postid3)

You can do it in the url, I just made it work recently. 您可以在url中进行操作,我最近才使它起作用。 This is from a python code, but the URL should work the same way. 这来自python代码,但URL应该以相同的方式工作。

"https://graph.facebook.com/?ids=" + ids[:-1] +
    "&fields=name,posts.limit(5).since(10+days+ago)" +
    "{from,to,full_picture,message,caption,description," +
    "link,name,shares,likes.summary(true)," +
    "comments.summary(true),created_time,is_hidden," +
    "message_tags,place,type,with_tags}")

This will get the last 5 posts from the last 10 days for several page ids. 这将获取过去10天中最后5个帖子的多个页面ID。 It will also get the total number of likes and comments as summary. 它还将获得喜欢和评论的总数作为摘要。

It took me a while to dig this info from the net, I found that since= has changed to since(). 我花了一些时间从网上挖掘此信息,我发现since =已更改为since()。

I tried to retrieve some reference where it's documented, so far with no success. 我试图检索记录在文档中的参考文献,但到目前为止没有成功。 I'll give you an update if I find it. 如果有的话,我会给你更新的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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