Created
August 9, 2012 19:58
-
-
Save khakimov/3307549 to your computer and use it in GitHub Desktop.
Wierd version of unfollow
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 'nokogiri' | |
require 'json' | |
require 'open-uri' | |
require 'oauth' | |
# Exchange your oauth_token and oauth_token_secret for an AccessToken instance. | |
# https://dev.twitter.com/apps here | |
def prepare_access_token(oauth_token, oauth_token_secret) | |
consumer = OAuth::Consumer.new("Consumer key", "Consumer secret", | |
{ :site => "http://api.twitter.com", | |
:scheme => :header | |
}) | |
# now create the access token object from passed values | |
token_hash = { :oauth_token => oauth_token, | |
:oauth_token_secret => oauth_token_secret | |
} | |
access_token = OAuth::AccessToken.from_hash(consumer, token_hash ) | |
return access_token | |
end | |
access_token = prepare_access_token("access token", "Access token secret") | |
url = 'https://api.twitter.com/1/friends/ids.json?cursor=-1&screen_name=khakimov' # use your user_name =) | |
doc = Nokogiri::HTML(open(url)) | |
doc2 = JSON.parse(doc) | |
doc2['ids'].each do |id| | |
p "#{id}" | |
response = access_token.request(:post, "https://api.twitter.com/1/friendships/destroy.json?user_id=#{id}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment