EzDevInfo.com

facebooker2

A simple facebook connect library for ruby

RoR omniauth and facebooker2

In a new application Rails 3.1 with only in Gemfile:

gem "omniauth" gem "facebooker2"

bundle install give the error:

Bundler could not find compatible versions for gem "hashie": In Gemfile: facebooker2 (= 0.0.16) ruby depends on hashie (~> 1.1.0) ruby

omniauth (>= 0) ruby depends on
  hashie (1.2.0)

How can I install facebooker2 with omniauth?


Source: (StackOverflow)

Using Mogli to check if a Page Has been Liked

I am using the Heroku hosted instant facebook application to implement a page tab canvas. I do not want the user to see the authorization popup that is shown by default with the standard heroku app. I would like to use the liked variable in the signed_request that is passed to the page.

I can't seem to find any docs on how to change the authentication method used with Mogli.

Can anyone advise?


Source: (StackOverflow)

Advertisements

Facebooker2 returning users UID but not name

I am just using the standard Facebooker2 setup.

        <%= fb_connect_async_js %>
            <% if current_facebook_user %>
              <%= "Hello #{fb_name(current_facebook_user, :useyou => false)}!" %>
              <%= fb_logout_link("Logout", request.url) %><br />
            <% else %>
              <%= fb_login_and_redirect('/login', :scope => 'user_about_me') %>
            <% end %>

What displays on the page is:

Hello <fb:name uid="73648576" useyou="false"></fb:name>

I am sure there's something very basic wrong here, but I've followed the instructions, done tutorials, wetc. and continue to get this result.

Any help most appreciated!


Source: (StackOverflow)

Facebook automatic login needing double page load on Rails 3

With Facebook logged in and app authenticated, a Rails 3 site with Facebooker2 needs 2 page reloads until it automatically logs in to Facebook.

How can I make passive login work on first page load?

ruby 1.9.3p125, rails 3.2.3, facebooker2 0.0.16


Source: (StackOverflow)

Not showing facebook connect button with Facebooker 2.0(RESOLVED)

I'm developing a rails application with Facebooker 2.0, my problem is that the facebook login button only appears when the user's in not already logged in in his facebook account, if the user is logged in, it disappears.

I´m using this code to show the button:

<%= fb_login_and_redirect("/users/create_facebook_user", :perms => 'email,user_birthday,offline_access') %>

Thank you for your help!


Source: (StackOverflow)

Specifying facebooker app id by domain

I have a RoR website at domain1.com that uses a facebook application linked to that domain.

I want to make domain2.com to point to the same server as domain1.com, so domain1.com/foo is equivalent to domain2.com/foo.

Obviously (I think) I need to make a second facebook application, because the one linked to domain1.com won't work if they visit the site under domain2.com.

However, I don't know how to tell facebooker2, in its facebooker.yml, to use one application if the request comes from one host or a different app if it comes from the other.

Is there any way to do this, or do something that achieves the same result?


Source: (StackOverflow)

Facebooker2. rails and create new user

I want to user facebooker2 for facebook connect functionality. So when the user login with facebook credentials i want to redirect to action create_facebook_user.

So I used this helper of facebooker2:

 <%= fb_login_and_redirect("/users/create_facebook_user", :perms => 'first_name,last_name,email,user_birthday') %>

OK? How can i access to facebook public information as email, first_name, last_name, etc.

My controller is:

def create_facebook_user
  if current_facebook_user
    @user = User.find_by_fb_user_id(current_facebook_user.id.to_i)
  end
  if @user.blank?
    @facebook_user = current_facebook_user.fetch

    @user = User.create :login => @facebook_user.email, :email => @facebook_user.email, :name => @facebook_user.name, :fb_user_id => @facebook_user.id
    if @user.save
      @user.profile = Profile.create(:benefactor_id => nil, :benefactor_invites =>   Setting.find_by_identifier("benefactor_invites").value.to_i)
      redirect_to :controller => "profiles", :action => "show", :id => @user.profile.id
    else
      render "new"
    end
  elsif @user.fb_user_id.nil?
    @user.update_attribute :fb_user_id, current_facebook_user.id
    redirect_to :controller => "dashboard", :url => "index"
  else
    redirect_to :controller => "dashboard", :url => "index"
  end
end

OK, my problem is to obtain user facebook information.


Source: (StackOverflow)

Facebooker2 current_facebook_user nil when logged in on Facebook

I've been trying to use Facebooker2 as a means to login via Facebook in Rails. However, Facebooker2's current_facebook_user function is somehow returning nil even though I'm definitely logged in on Facebook. Any ideas? Thanks!

Here's the gist of my code:

In one of my controllers:

def check_login
    if current_facebook_user.nil?
        "This always gets returned, even though I'm logged into Facebook."
    else
        "This never gets run"
    end
end

Facebook JS. The line in FB.Event.subscribe('auth.login', function(response) { ... } redirects to the check_login function above.

<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId : '123456789012345',
            status : true,  // check login status
            cookie : true,  // enable cookies to allow the server to access the session
            channelUrl : 'true',  // add channelURL to avoid IE redirect problems
            xfbml : true  // parse XFBML
        });
        FB.Event.subscribe('auth.login', function(response) {
            window.location = "http://www.mysite.com/check_login";
        });
    }; ( function() {
        var s = document.createElement('div');
        s.setAttribute('id', 'fb-root');
        document.documentElement.getElementsByTagName("body")[0].appendChild(s);
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        s.appendChild(e);
    }());
    function logout() {
        FB.logout();
        window.location = 'http://www.mysite.com/logout';
    };
</script>

Source: (StackOverflow)

Facebook Post as a image

I wants to post a post on Facebook as a Image not a text (and not as album too) , And I'm using below code :

def facebook_page
@page ||= Mogli::Page.new(:id => facebook_page_id, :client => Mogli::Client.new(facebook_page_token))
end

def post_to_facebook_page()
    post_params = {
    :message     => "message,"
    :link        => "url.jpeg"
    :name        => "name",
    :description => "description",
    :picture     => "picture_url"
   } 
    facebook_page.feed_create(Mogli::Post.new(post_params))
    rescue Mogli::Client::OAuthException, Mogli::Client::HTTPException => e
   Rails.logger.error("Unable to post to Facebook page #{facebook_page_id} due to #{e.message} on #{Time.now}")
end

But it is not posting as I expected : Here is the output: http://www.facebook.com/profile.php?id=100004124073785 all posts are as a text and

I expected :

http://www.facebook.com/bigjoneschicago?fref=ts find first post "Handmade pasta new on the menu tonight" , Could any one help me on this.


Source: (StackOverflow)

facebook token expiration issue

I've integrated facebook with my app using facebooker2 and Mogli. Now offline_access is removed from the facebook. I'm able to get token but its getting expire in 2 hrs, also If user get logged out from facebook, Its also get expired.

I wanted to renew the tokens but I can not do that by following code

https://graph.facebook.com/oauth/access_token?             
client_id=APP_ID&
client_secret=APP_SECRET&
grant_type=fb_exchange_token&
fb_exchange_token=EXISTING_ACCESS_TOKEN 

As I could not get when user get logged out from the user. If any how I can know when user get logged out from Facebook , still I can not exchange the tocken as its already get expired. and access_token only works before the expiration of a token.

Any Idea, if I have 60 days expiration token or renew the token before get expired.

Thanks in advance for any help you are able to provide.


Source: (StackOverflow)

Rails facebook app and Third party UID's

I have a rails facebook app that uses Facebooker2 and the blog post says they are moving to third party uid's instead of normal uid's. What would it take to make the migrations to keep my app working?


Source: (StackOverflow)

rails gem outputting broken javascript

I've been using this gem for my facebook canvas app: https://github.com/dekart/facebooker2.git

Today I swapped it out for another facebook auth gem, decided I didn't like it and went back to my original.

I'm including the gem like this:

gem 'facebooker2', :git => "https://github.com/dekart/facebooker2.git"

Since I've made this change, the facebooker2 gem has being causing javascript errors in my app.

 window.fbAsyncInit = function() {
                        FB.init({
          appId  : 'myappid',
          status : true, // check login status
          cookie : true, // enable cookies to allow the server to access the session
          xfbml  : true,  // parse XFBML
          oauth  : true
          channelUrl : 'http://myurl/channel.html'
        });

There is a missing comma after the oauth: true this means my facebook login button will not render.

How do I fix this? Ideally, I'd like to go into the gem, see why it's missing the comma and fix it. Then use my fixed version of the gem on my local machine and on heroku. If you can offer an alternative solution, it would be much appreciated.


Source: (StackOverflow)

facebook connect using ajax in ror (facebooker2)?

Relatively simple question here but I can't seem to figure it out. I have an application where the user submits a get request and is then given a page with results. On this page, the user can login to facebook to interact with the results (rate, comment etc). However, how do I connect the user to facebook and keep him on the same page. (I cant just refresh with the get query in the url because the page returns something different every time.)

In other words, given this code from the facebooker2 github:

<%= fb_connect_async_js %>
<% if current_facebook_user %>
  <%= "Welcome #{current_facebook_user.first_name} #{current_facebook_user.last_name}!" %>
  or 
  <%= "Hello #{fb_name(current_facebook_user, :useyou => false)}!" # link to facebook profile %>
  <%= fb_logout_link("Logout of fb", request.url) %><br />
<% else
   # you must explicitly request permissions for facebook user fields.
   # here we instruct facebook to ask the user for permission for our website
   # to access the user's facebook email and birthday
   %>
  <%= fb_login_and_redirect('<your URL here>', :perms => 'email,user_birthday') %>
<% end %>

How can I not redirect the user to another page (url is blank), and have the first part of the if statement automatically execute once the user signs into facebook.


Source: (StackOverflow)

Rails-facebooker2, current_facebook_user throw error when facebooks' user is logged in

I am using facebooker2 in Rails 2.3.5 (ruby 1.8.6, and there's no possibility to upgrade its version), and the method current_facebook_user is throwing a error when the facebook's user is already logged in.

what i want to achieve is that the method current_facebook_user returns the facebook user's data when is logged in.

thanks in advance.


Source: (StackOverflow)

Multiple Facebook apps with Facebooker2

I'm working on a rails app that powers multiple facebook apps (serving them via iFrame) and allows users to install / customize the different apps from an admin area in my app.

I'm using the Facebooker2 gem and noticed that I can only specify one app_id and app_secret in the Facebooker.yml config file. Any tips on how I can modify it to support multiple Facebook apps.

My first thought would be to store the app_id's and app_secret's for my apps in the database then have Facebooker dynamically load them accordingly from there.

Any advice would be much appreciated!


Source: (StackOverflow)