diff --git a/README.markdown b/README.markdown index e597f01..5839934 100644 --- a/README.markdown +++ b/README.markdown @@ -37,13 +37,7 @@ Go to [`http://localhost:4567/`](http://localhost:4567/), and through the power get "/profile" do token = FacebookToken.new(session[:facebook]) - me = JSON.parse(token.get("/me")) - @profile = { - :id => me["id"], - :name => me["name"], - :photo => "https://graph.facebook.com/#{me["id"]}/picture", - :url => me["link"] - } + @me = JSON.parse(token.get("/me")) haml :show end @@ -54,17 +48,17 @@ Go to [`http://localhost:4567/`](http://localhost:4567/), and through the power %title Passport Sinatra %body = yield - + @@ index %form{:action => "/", :method => :post} %input{:type => :hidden, :name => :oauth_provider, :value => :facebook} %input{:type => :hidden, :name => :authentication_type, :value => :user} %input{:type => :submit, :value => "Login with Facebook"} - + @@ show - %a{:href => @profile[:url]} - %h1 Your on Facebook! - %img{:src => @profile[:photo]} + %a{:href => @me["link"]} + %h1= "#{@me["name"]}, Your on Facebook!" + %img{:src => "https://graph.facebook.com/#{@me["id"]}/picture"} The magic happens here: diff --git a/app.rb b/app.rb index 41aa2dc..c38ab07 100644 --- a/app.rb +++ b/app.rb @@ -23,13 +23,7 @@ get "/profile" do token = FacebookToken.new(session[:facebook]) - me = JSON.parse(token.get("/me")) - @profile = { - :id => me["id"], - :name => me["name"], - :photo => "https://graph.facebook.com/#{me["id"]}/picture", - :url => me["link"] - } + @me = JSON.parse(token.get("/me")) haml :show end @@ -48,6 +42,6 @@ %input{:type => :submit, :value => "Login with Facebook"} @@ show -%a{:href => @profile[:url]} - %h1 Your on Facebook! - %img{:src => @profile[:photo]} \ No newline at end of file +%a{:href => @me["link"]} + %h1= "#{@me["name"]}, Your on Facebook!" + %img{:src => "https://graph.facebook.com/#{@me["id"]}/picture"} \ No newline at end of file