0

私はRails関数を書いています(すべきです)

  1. すべてのユーザーをインポートする'/me / music'
  2. 50のグループで各ページをより詳細に検索します(FBバッチAPI)

インポート私はうまく機能しています。バッチはループを最初の50に制限することで機能しますが、オフセットを使用してループを再実行する方法がわかりません。これは私の現在のループです:

Koala::Facebook::BatchOperation.instance_variable_set(:@identifier, 0)
results = @graph.batch do |batch_api|
  @music.each do |artist|
    if(i == 50)
    break
    end
    batch_api.get_object(artist["id"])
    i=i+1
  end
end

どうやら@music[0..50] do |artist|有効な構文ではないので、そこには運がありません。

4

1 に答える 1

3

グーガーにとって、これは私が私の問題を解決した方法です:

artist_ids = music.each do |artist|
  artist["id"]
end
Koala::Facebook::BatchOperation.instance_variable_set(:@identifier, 0)
artist_ids.in_groups_of(50) do |artists|
  i=0
  results = graph.batch do |batch_api|
    for artist in artists do
      # ((Your code))
      i=i+1
    end
  end
  results.each do |artist|
      # ((Your code))
  end
end
于 2012-04-20T15:40:34.527 に答える