-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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