1

Facebook では、誰 (どのユーザー) が Facebook ページの投稿にコメントしたかを知る必要があります。javascript ファイルで facebook-batch-requests を使用して 2 つのリクエストを作成します。1 つ目はすべての投稿に対して、2 つ目は各投稿のリクエストが必要です。コメントのある投稿だけを選択できれば幸いです。

FB.api('/', 'POST', {
  batch: [
  {
    // all posts from page from last year
    'method': 'GET',
    'name': 'posts_page_year',
    'omit_response_on_success': false,
    'relative_url': fbPageID + '/posts?since=2012-01-01&until=' + timeNow + '&limit=200000'
  },
  {
    // all post-ids from last year
    'method': 'GET',
    "relative_url": "/{result=posts_page_year:$.data.*.id[?(@.comments.count!=0)]}"
  }
]
}, function(response) {
  callback(response);
}
);

私の問題は 2 番目のバッチ リクエストで、エラーが返されます (#803)。少し出してみました。

{
    // all post-ids from last year
    'method': 'GET',
    "relative_url": "/{result=posts_page_year:$.data.0.id}"
}

最初のポストリクエストでオブジェクトを返します。すべてが良いです。しかし、最初の投稿だけでなく、すべての投稿でこれが必要です。

{
    // all post-ids from last year
    'method': 'GET',
    "relative_url": "/{result=posts_page_year:$.data.*.id}"
}

エラー (#803) を返します。リクエストしたエイリアスの一部が存在せず、すべての ID のリストが返されます。

{
    // all post-ids from last year
    'method': 'GET',
    "relative_url": "/{result=posts_page_year:$.data.*.id[?(@.comments.count!=0)]}"
}

次のエラーが返されます: (#803) リクエストしたエイリアスの一部が存在しません: {result=posts_page_year:$.data.*.id[

私はほとんどすべてを試してみましたが、問題を解決する方法がわからないため、あなたの助けが必要です. THX!

4

2 に答える 2

0
FB.api('/', 'POST', {
  batch: [
    {
      // 0: all likes from user
      'method': 'GET',
      'relative_url': 'me/likes'
    },
    {
      // 1: all user-posts from last month
      'method': 'GET',
      'relative_url': 'me/posts?since=' + timeMonthAgo + '&until=' + timeNow + '&limit=200000'
    },
    {
      // 2: all user-posts from last year
      'method': 'GET',
      'relative_url': 'me/posts?since=' + timeYearAgo + '&until=' + timeNow + '&limit=200000'
    }
  ]
  }, function (response) {
    callback(response);
  }
);

制限を設定する必要があったため、各応答の内容が制限されました。無理な数まで制限を設けることが可能です。sinceパラメータとパラメータを使用して時間範囲も設定する必要がありuntilます。

これが誰かに役立つことを願っています。

于 2014-10-27T07:41:04.223 に答える