Created
December 27, 2012 01:42
-
-
Save anonymous/4384731 to your computer and use it in GitHub Desktop.
See what you made me do, Twitter? This is what happens when you opt people into unwanted emails and then don't have an API mechanism for unsubscribing.
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
def disable_notifications! | |
auth_url = "https://twitter.com/login" | |
notifications_url = "https://twitter.com/settings/notifications" | |
agent = Mechanize.new | |
page = agent.get(auth_url) | |
puts "DISABLING NOTIFICATIONS for #{self.username}" | |
puts "Logging in..." | |
page.forms_with(:action => 'https://twitter.com/sessions') do |forms| | |
f = forms.first | |
f.set_fields('session[username_or_email]' => self.username, 'session[password]' => self.password) | |
page = agent.submit(f, f.buttons.first) | |
end | |
page = agent.get(notifications_url) | |
puts "Updating notifications..." | |
page.forms_with(:action => 'https://twitter.com/settings/notifications/update') do |forms| | |
form = forms.first | |
# uncheck ALL the boxes! | |
form.checkboxes_with(:name => /^user/).each do |field| | |
field.uncheck | |
end | |
page = agent.submit(form, form.buttons.first) | |
puts "DONE" | |
end | |
nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment