facebook api:计算活动的参加者数量(限制问题)

发布于 2024-10-25 07:29:40 字数 743 浏览 1 评论 0原文

好吧,通常我对 facebook API 没什么问题,但我遇到了一个让我想知道的问题。 (我认为这是一个错误(检查票证 http://bugs.developers.facebook。 net/show_bug.cgi?id=13694),但如果有人有想法,我想把它扔在这里)。

我正在使用 facebook PHP 库来计算特定活动的所有与会者,

$attending = $facebook->api('/'.$fbparams['eventId'].'/attending');

这可以正常工作,它可以正确返回包含所有与会者的数组...

现在问题是:

此活动现在有大约 18.000 名与会者。 API 调用返回最多 992 名与会者(而不是应有的 18000 人)。

我尝试

$attending = $facebook->api('/'.$fbparams['eventId'].'/attending?limit=20000');

进行测试,但它没有改变任何东西。

所以我真正的问题是:

如果我无法通过使用图形 api 让它工作,什么是一个好的替代方案? (也许解析事件页面的 html?)现在我每隔几个小时手动更改该值,这是乏味且不必要的。

Okay normally I'm all fine about the facebook API but I'm having a problem which just keeps me wondering. (I think it's a bug (Check ticket http://bugs.developers.facebook.net/show_bug.cgi?id=13694) but I wanted to throw it here if somebody has an idea).

I'm usng the facebook PHP library to count all attendees for a specific event

$attending = $facebook->api('/'.$fbparams['eventId'].'/attending');

this works without a problem it correctly returns an array with all attendees...

now heres the problem:

This event has about 18.000 attendees right now.
The api call returns a max number of 992 attendees (and not 18000 as it should).

I tried

$attending = $facebook->api('/'.$fbparams['eventId'].'/attending?limit=20000');

for testing but it doesn't change anything.

So my actual question is:

If I can't get it to work by using the graph api what would be a good alternative? (Parsing the html of the event page maybe?) Right now I'm changing the value by hand every few hours which is tedious and unnecessary.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

囍孤女 2024-11-01 07:29:41

实际上有两个参数,limitoffset。我认为您必须同时使用两者并继续拨打电话,直到其中一个返回的值小于最大值。限制。

像这样的东西,但是采用递归方法(我正在编写伪代码):

offset = 0;
maxLimit = 992;
totalAttendees = count(result)

if (totalAttendees >= maxLimit)
{
  // do your stuff with each attendee
  offset += totalAttendees;
  // make a new call with the updated offset
  // and check again
}

Actually there are two parameters, limit and offset. I think that you will have to play with both and continue making calls until one returns less than the max. limit.

Something like this, but in a recursive approach (I'm writting pseudo-code):

offset = 0;
maxLimit = 992;
totalAttendees = count(result)

if (totalAttendees >= maxLimit)
{
  // do your stuff with each attendee
  offset += totalAttendees;
  // make a new call with the updated offset
  // and check again
}
七秒鱼° 2024-11-01 07:29:41

我搜索了很多,这就是我修复它的方法:
请求的网址应类似于

<一href="https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=738667559524648%3Faccess_令牌%3D603913936305026%257CyZYvULhJhDcrsVaGzJmendOpHDw%26fields%3Dattending_count%2Cinvited_count&version=v2.2" rel="nofollow">这里是您可以测试它的地方,这是我使用的代码:

function events_get_facebook_data($event_id) {
  if (!$event_id) {
    return false;
  }

  $token = klicango_friends_facebook_token();
  if ($token) {
    $parameters['access_token'] = $token;
    $parameters['fields']= 'attending_count,invited_count';
    $graph_url = url('https://graph.facebook.com/v2.2/' . $event_id , array('absolute' => TRUE, 'query' => $parameters));
    $graph_result = drupal_http_request($graph_url, array(), 'GET');
    if(is_object($graph_result) && !empty($graph_result->data)) {
      $data = json_decode($graph_result->data);
      $going = $data->attending_count;
      $invited = $data->invited_count;
      return array('going' => $going, 'invited' => $invited);
    }
    return false;
  }

  return false;
}

I've searched a lot and this is how I fixed it:
The requested URL should look something like this.

Here is where you can test it and here is the code I used:

function events_get_facebook_data($event_id) {
  if (!$event_id) {
    return false;
  }

  $token = klicango_friends_facebook_token();
  if ($token) {
    $parameters['access_token'] = $token;
    $parameters['fields']= 'attending_count,invited_count';
    $graph_url = url('https://graph.facebook.com/v2.2/' . $event_id , array('absolute' => TRUE, 'query' => $parameters));
    $graph_result = drupal_http_request($graph_url, array(), 'GET');
    if(is_object($graph_result) && !empty($graph_result->data)) {
      $data = json_decode($graph_result->data);
      $going = $data->attending_count;
      $invited = $data->invited_count;
      return array('going' => $going, 'invited' => $invited);
    }
    return false;
  }

  return false;
}

野心澎湃 2024-11-01 07:29:41

尝试

SELECT eid , attend_count, unsure_count,all_members_count FROM event WHERE eid ="event"

Try

SELECT eid , attending_count, unsure_count,all_members_count FROM event WHERE eid ="event"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文