Skip to content

Instantly share code, notes, and snippets.

@josefrichter
Created September 11, 2010 08:33
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 josefrichter/574993 to your computer and use it in GitHub Desktop.
Save josefrichter/574993 to your computer and use it in GitHub Desktop.
<% fb_connect_async_js do %>
<% unless current_facebook_user %>
FB.login(function(response) {
if (response.session) {
// window.location.href = '#{request.url}';
window.location.href = '<%= root_url %>';
} else {
// user cancelled login
}
}, {perms:'read_stream,offline_access,email,user_status,user_interests,user_location,user_online_presence'});
<% end %>
<% end %>
<% if current_facebook_user %>
<%= debug @user.friends %> <!-- in controller: @user = current_facebook_user.fetch -->
<%= "Welcome #{@user.name}!" %>
<%= fb_profile_pic(current_facebook_user) %>
<%= fb_logout_link("Logout of fb", request.url) %><br />
<table><!-- list friends -->
<% for friend in @user.friends do %>
<tr><td><%= fb_profile_pic(friend.id) %></td><td><%= friend.name %></td></tr>
<% end %>
</table>
<% else %>
<h1>app not authorized.</h1>
<%= fb_login_and_redirect('#{ root_url }', :perms => 'read_stream,offline_access,email,user_status,user_interests,user_location,user_online_presence') %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment