Skip to content

Instantly share code, notes, and snippets.

/fullcontact.rb Secret

Created December 23, 2015 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8efa00ac01a184bd8238 to your computer and use it in GitHub Desktop.
Save anonymous/8efa00ac01a184bd8238 to your computer and use it in GitHub Desktop.
Helps you find which of your customers are the most active on social media.
require 'open-uri'
require 'json'
emails = IO.readlines("customers.md")
emails.each do |line|
line.chomp!
end
report = emails.map { |e| sleep(2) ; JSON.parse open("http://api.fullcontact.com/v2/person.json?email=#{e}&apiKey=######").read rescue OpenURI::HTTPError }.to_json
File.write( '.json', report)
@bublik
Copy link

bublik commented Dec 23, 2015

require 'open-uri'
require 'json'

api_key = '####'
emails = IO.readlines("customers.md")

f = File.open('customers.json', 'w')
emails.each do |email|
email.chomp!
begin
response = open("http://api.fullcontact.com/v2/person.json?email=#{email}&apiKey=#{api_key}").read
#v1
user_data = JSON.parse(response) # data in hash
f.write(user_data['any_key']) # you can store special field
#v2
#f.write(response) # store json response and parse lately
rescue => e
puts e.message
end
end
f.close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment