Skip to content

Instantly share code, notes, and snippets.

@fukayatsu
Created April 9, 2020 07:48
Show Gist options
  • Save fukayatsu/60850532bc8b4c64222ce3f51f1f21a6 to your computer and use it in GitHub Desktop.
Save fukayatsu/60850532bc8b4c64222ce3f51f1f21a6 to your computer and use it in GitHub Desktop.
Fetch all posts in the team using esa-ruby
require 'esa'
client = Esa::Client.new(access_token: "***", current_team: 'foo')
since_number = 0
loop do
posts = client.posts(q: "sort:number-asc number:>#{since_number}", per_page: 100).body['posts']
break if posts.empty?
puts "number: #{posts.first['number']}~#{posts.last['number']}"
# Your code goes here
since_number = posts.last['number']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment