Created
March 15, 2010 18:33
-
-
Save adriand/333152 to your computer and use it in GitHub Desktop.
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
post '/value' do | |
screen_name = params[:screen_name] | |
if screen_name && screen_name != "" | |
@info = Twitter.get('/1/users/show.json', :query => { :screen_name => screen_name }) | |
if @info['error'] | |
redirect "/?failure=There was an error retrieving your account information. Twitter says: #{info['error']}." | |
else | |
# Since we've now successfully retrieved information on a user account, we'll either look up or save this user in our | |
# database. | |
person = Person.first(:screen_name => screen_name) | |
unless person | |
person = Person.new( | |
:screen_name => screen_name, | |
:name => @info['name'], | |
:joined_twitter_at => DateTime.parse(@info['created_at']) | |
) | |
end | |
# These attributes can change over time | |
person.followers_count, person.statuses_count, person.profile_image_url = @info['followers_count'], @info['statuses_count'], @info['profile_image_url'] | |
person.save | |
redirect "/w/#{person.screen_name}" | |
end | |
else | |
redirect "/?failure=Please enter a Twitter username to start the valuation process." | |
end | |
end | |
# The shorter the url, the better for Twitter | |
get '/w/:screen_name' do | |
@person = Person.first(:screen_name => params[:screen_name]) | |
@page_title = @person.name | |
haml :person | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment