This file contains hidden or 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
require 'rubygems' | |
require 'active_record' | |
require 'yaml' | |
config = YAML::load(File.open(File.expand_path('../../config/database.yml', __FILE__))) | |
ActiveRecord::Base.establish_connection(config["production"]) | |
ActiveRecord::Migrator.migrate(File.expand_path('../../db/migrate', __FILE__) ) |
This file contains hidden or 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
Facebooker2.load_facebooker_yaml |
This file contains hidden or 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
class ApplicationController < ActionController::Base | |
include Facebooker2::Rails::Controller | |
# Needed to support IE 6 and 7 | |
before_filter :set_p3p_header_for_third_party_cookies | |
# Add an :except here if you have controllers that you want to | |
# allow non-users to access | |
before_filter :ensure_application_is_installed |
This file contains hidden or 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
# Unique Facebook ID of this user | |
facebook_id = current_facebook_user.id | |
# The OAuth token, this is how you access the user at a later point | |
token = current_facebook_client.access_token | |
# OAuth token expiration. Save this off, you'll need this to recreate | |
# the user later | |
expiration = current_facebook_client.expiration.to_i | |
name = current_facebook_user.name | |
# Gets an array of Mogil::Users |
This file contains hidden or 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
require 'lib/facebooker-1.0.69/lib/facebooker/rails/helpers/stream_publish' | |
require 'lib/facebooker-1.0.69/lib/facebooker/rails/helpers/fb_connect' | |
require 'lib/facebooker-1.0.69/lib/facebooker/rails/helpers' | |
require 'lib/facebooker-1.0.69/lib/facebooker/rails/facebook_form_builder' | |
module ApplicationHelper | |
include Facebooker::Rails::Helpers | |
... | |
end |
This file contains hidden or 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
module Facebooker | |
def self.api_key | |
unless @_api_key | |
config = (YAML.load(ERB.new(File.read(File.join(::Rails.root,"config","facebooker.yml"))).result)[::Rails.env]) | |
@_api_key = config["api_key"] | |
end | |
@_api_key | |
end |
This file contains hidden or 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
# load access token and expiration from database | |
client = Mogli::Client.new(access_token, expiration) | |
user = Mogli::User.find(facebook_id, client) | |
post = {:name => "main title for the post", | |
:caption => "Sub title for the post", | |
:description => "Long description for the post", | |
:picture => "url to a picture for the post", | |
:link => "url to go to when the user clicks on the title", | |
:from => {:name => "Your app's name", | |
:category => "Your app's category", |
This file contains hidden or 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
require 'openssl' | |
require 'base64' | |
require 'json' | |
# Facebook's base64 algorithm is a special "URL" version of the algorithm. | |
def base64_url_decode(str) | |
str += '=' * (4 - str.length.modulo(4)) | |
Base64.decode64(str.tr('-_','+/')) | |
end |
This file contains hidden or 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
import sbt._ | |
val output : String = Process("command to run").!! | |
val returnCode: Int = Process("command to run").! |
This file contains hidden or 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
// 2.4 is currently the latest but will only work with Scala 2.9 | |
val liftJson = "net.liftweb" %% "lift-json" % "2.3" |