Created
April 13, 2012 16:54
-
-
Save zalary/2378323 to your computer and use it in GitHub Desktop.
zal_debacle_001
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'csv' | |
require 'uri' | |
gem 'curb' | |
require 'curb' | |
# open the csv file | |
f = File.open("altria-delete.csv", "r") | |
count = 0 | |
# loop through each record in the csv file, adding | |
# each record to our array. | |
f.each_line { |line| | |
count += 1 | |
# each line has fields separated by commas, so split those fields | |
fields = line.split(',') | |
# do a little work here to urlencode spaces and @ signs | |
leadid = fields[0] | |
#.gsub!("@","%40") | |
action = "/delete/" | |
#reason = fields[1].gsub!(" ","%20") | |
puts "#{leadid}#{action}" | |
c = Curl::Easy.http_post("https://api.leadconduit.com/leads/#{leadid}#{action}", Curl::PostField) | |
c.http_auth_types = :basic | |
c.username = '' | |
c.password = '' | |
c.perform | |
c.verbose = true | |
unless c.response_code < 201 | |
# reports to the screen when manually ran that the site is down | |
open('leadeventreturnlog.txt', 'a') { |f| | |
f.puts " #{leadid}, #{c.body_str} " | |
} | |
end | |
puts "FINISHED: #{c.response_code} #{c.body_str}" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment