Skip to content

Instantly share code, notes, and snippets.

@SathyaBhat
Created April 1, 2012 08:00
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 SathyaBhat/2273068 to your computer and use it in GitHub Desktop.
Save SathyaBhat/2273068 to your computer and use it in GitHub Desktop.
Ruby code to go through home timeline & expand t.co URLs
require 'twitter'
def setup_twitter()
Twitter.configure do |config|
config.consumer_key = ""
config.consumer_secret = ""
config.oauth_token = ""
config.oauth_token_secret = ""
end
twitter = Twitter::Client.new
end
twitter = setup_twitter()
tweets = twitter.home_timeline
tweets.each do |ht|
t = twitter.status(ht.id, :include_entities => true)
expanded_link = t.urls[0].expanded_url unless t.urls.empty?
link = t.urls[0].url unless t.urls.empty?
links = "URL: #{link} expands to #{expanded_link}" unless link.nil?
puts "Status: #{ht.text} #{links}"
end
@SathyaBhat
Copy link
Author

yo @iambibhas. Pls to excuse. Testing something,

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