Skip to content

Instantly share code, notes, and snippets.

@renatodex
Created August 27, 2015 18:33
Show Gist options
  • Save renatodex/969718690296e740f82f to your computer and use it in GitHub Desktop.
Save renatodex/969718690296e740f82f to your computer and use it in GitHub Desktop.
A Script to extract all followers using the Instagram API
require 'open-uri'
require 'json'
require 'typhoeus'
def generate_resultset(url)
output = []
result = JSON.parse(Typhoeus.get(url).body)
output += result['data'].inject([]) do |arr,d|
arr << d['username']
arr
end
puts "Fetching API Url #{url}"
if !result['pagination'].empty?
output += generate_resultset(result['pagination']['next_url'])
else
output
end
end
# This is where you insert your first image (then it will loop indefinitivelly until the end of universe)
start_url = "https://api.instagram.com/v1/users/416240579/followed-by?access_token=416240579.xxxxx"
output = generate_resultset(start_url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment