如何通过Facebook图表api获取一个组的所有帖子 [英] How to get all posts of a group via facebook graph api

查看:102
本文介绍了如何通过Facebook图表api获取一个组的所有帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Facebook组中获取参考其ID的所有帖子。我试过这个:

I want to grab all the posts from the facebook group with reference to its ID. I tried this:

https://graph.facebook.com/".$group_id."/feed?time_format=U&".$authToken

这只给我一些帖子,我想让所有的帖子都被一个单一的url,如果可能的话,如果不是通过分页网址,但分页网址包含分页令牌作为

which only gives me certain posts. I want all the posts to be retrieved by a single url if possible if not by pagination url. But pagination url contains paging token as

https://graph.facebook.com/55259308085/feed?limit=500&access_token=ACCESS_TOKEN&until=1298025645&__paging_token=55259308085_10150259582898086

什么是分页令牌,直到??

What is paging token and Until ??

请指示我正确的路径
谢谢。

Please direct me to the right path. Thank you.

推荐答案

set_time_limit(99999999);
ini_set('memory_limit', "9999M");

function fetchUrl($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 40);

    $data = curl_exec($ch);
    curl_close($ch);

    return $data;
}

$url_array = array();

function recurse_it($url, $c) {
    global $url_array;
    $feeds         = fetchUrl($url);
    $feed_data_obj = json_decode($feeds, true);
    if (!empty($feed_data_obj['data'])) {
        $next_url      = $feed_data_obj['paging']['next'];
        $url_array[$c] = $next_url;
        recurse_it($next_url, $c + 1);
    }
    return $url_array;
}

$url = "https://graph.facebook.com/55259308085/groups?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$arr = recurse_it($url, 0);
print_r($arr);

其中 $ arr 是一个全部数组可用的分页链接,我使用foreach循环遍历分页的所有内容。

如果需要,我可以提供更多的解释。

Where $arr is an array of all the available pagination links for which I used a foreach to loop through all the contents of the pagination.
I can provide more explanation in case it's needed.

这篇关于如何通过Facebook图表api获取一个组的所有帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆