Facebooker2 using Mogli request

Provides rails helpers for interfacing with Facebook’s OpenGraph Javascript API.

Example

1. You need a facebook app. Have your API Key, Application Secret, and Application ID handy.
2. Add to your Gemfile

gem 'facebooker2'
gem 'mogli'

3. Create config/facebooker.yml with the appropriate environment.

production:
  app_id: <your application id>
  secret: <your application secret>
  api_key: <your application key>

4. Create config/initializers/facebooker2.rb and place the following line in it

Facebooker2.load_facebooker_yaml

5. Add the following line to your app/controllers/application_controller.rb add it right after the line class

class ApplicationController < ActionController::Base
  include Facebooker2::Rails::Controller

def post_to_my_wall(msg, picture)
    current_facebook_user.feed_create(Mogli::Post.new(
        :message => "#{msg}",
        :picture => "#{picture}"
      ))
  end

  def post_to_friend_wall(uid, msg, picture)
    client = current_facebook_client   

    friend = Mogli::User.find(uid, client, link)
    friend.feed_create(Mogli::Post.new(
        :message => "#{msg}",
        :picture => "#{picture}",
        :link => "#{link}"
      ))
  end
end

6. for Authenticator user Install Facebooker2 for Rails 3

Advertisements

About me
Interested about Ruby on Rails

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: