2

trying to get every post and comment from a facebook page, I made this function that should go through the pagination:

$req = $facebook->api("/" . $pagename . "/?fields=posts.fields(message,link,created_time,shares,likes,comments)");

function parcours_arbre($ab)
{
  GLOBAL $facebook;
  GLOBAL $pagename;
  $next = create_request($ab['posts']['paging']['next']);
  $next_req = $facebook->api($pagename.$next);
  $ab_next = $next_req['data'];
  $prev = create_request($ab['posts']['paging']['previous']);
  $prev_req = $facebook->api($prev);
  $ab_prev = $prev_req['data'];
  if (empty($ab)) {
    display_results($ab['posts']['data']);
  } else {
    parcours_arbre($ab_next);
    parcours_arbre($ab_prev);
  }
}

I unfortunately get the following error:

Notice: Undefined index: posts in /form.php on line 36

Notice: Undefined offset: 3 in /utils.php on line 20

Notice: Undefined offset: 4 in /utils.php on line 20

Fatal error: Uncaught GraphMethodException: Unsupported get request. thrown in /sdk/src/base_facebook.php on line 1271

Any idea how i could avoid it or what is going on? Would this go away if i use the "until" statement in my api request? Thanks a lot,

4

1 回答 1

1

解释每个错误

  • 作为函数参数的变量 $ab 没有“posts”索引。您应该尝试使用var_dump此变量,以便查看它的实际外观。
  • 和上面一样
  • 和上面一样
  • api函数需要 3。路径应该是@pagename. 该方法(“GET”或“POST”)很可能是 POST,因为 GET 导致错误。参数,应该是array("fields" => "posts.fields(message,link,created_time,shares,likes,comments)")

我注意到接下来你有代码

$next_req = $facebook->api($pagename.$next);

但对于以前你有

$prev_req = $facebook->api($prev);

可能想调查一下。

于 2013-09-06T14:15:05.577 回答