Permalink
Browse files

Added setInfo and pretty errors

git-svn-id: svn+ssh://rubyforge.org/var/svn/facebooker/trunk/facebooker@217 06148572-b36b-44fe-9aa8-f68b04d8b080
  • Loading branch information...
1 parent 1b579de commit a4985c1d2a728d7c44972427106a239c3be45598 mmangino committed Jun 12, 2008
View
@@ -5,7 +5,7 @@
require 'facebooker/rails/facebook_asset_path'
require 'facebooker/rails/facebook_request_fix'
require 'facebooker/rails/routing'
-
+require 'facebooker/rails/facebook_pretty_errors'
module ::ActionController
class Base
def self.inherited_with_facebooker(subclass)
View
@@ -22,6 +22,8 @@
require 'facebooker/models/applicationproperties'
require 'facebooker/models/tag'
require 'facebooker/models/user'
+require 'facebooker/models/info_item'
+require 'facebooker/models/info_section'
module Facebooker
class << self
@@ -0,0 +1,10 @@
+module Facebooker
+ class InfoItem
+ include Model
+ attr_accessor :label, :image,:description, :link
+
+ def to_json
+ {:label=>label,:image=>image,:description=>description,:link=>link}.to_json
+ end
+ end
+end
@@ -0,0 +1,10 @@
+module Facebooker
+ class InfoSection
+ include Model
+ attr_accessor :field, :items
+
+ def to_json
+ {:field=>field,:items=>items}.to_json
+ end
+ end
+end
@@ -169,6 +169,12 @@ def set_profile_fbml(profile_fbml, mobile_fbml, profile_action_fbml)
session.post('facebook.profile.setFBML', parameters)
end
+ def set_info(title,sections,format=:text)
+ format_id = format.to_s == "text" ? 1 : 5
+ sections = [sections] unless sections.is_a?(Array)
+ session.post('facebook.profile.setInfo',{:title=>title,:info_fields=>sections.to_json,:type=>format_id,:uid=>id},false)
+ end
+
##
# Set the status of the user
#
@@ -252,6 +252,13 @@ def self.process(data)
first_child.nil? ? [] : [first_child.name, array_of_hashes(root, first_child.name)]
end
end
+
+ class SetInfo < Parser#:nodoc:
+ def self.process(data)
+ raise data
+ element('fbml_setRefHandle_response', data).text_value
+ end
+ end
class SetRefHandle < Parser#:nodoc:
def self.process(data)
@@ -432,7 +439,8 @@ class Parser
'facebook.groups.get' => GroupsGet,
'facebook.events.getMembers' => EventMembersGet,
'facebook.groups.getMembers' => GroupGetMembers,
- 'facebook.notifications.sendEmail' => NotificationsSendEmail
+ 'facebook.notifications.sendEmail' => NotificationsSendEmail,
+ 'facebook.profile.setInfo' => SetInfo
}
end
@@ -0,0 +1,14 @@
+if RAILS_ENV=="development"
+ class ActionController::Base
+ def rescues_path_with_facebooker(template_name)
+ t="#{RAILS_ROOT}/vendor/plugins/facebooker/templates/#{template_name}.erb"
+ File.exist?(t) ? t : rescues_path_without_facebooker(template_name)
+ end
+
+ alias_method_chain :rescues_path,:facebooker
+
+ def response_code_for_rescue(exception)
+ 200
+ end
+ end
+end
@@ -10,6 +10,7 @@ def initialize(api_base, api_path, api_key)
# TODO: support ssl
def post(params)
+ puts params.to_json
Parser.parse(params[:method], Net::HTTP.post_form(url, params))
end
@@ -402,9 +402,9 @@ def batch(serial_only=false)
BatchRun.current_batch=nil
end
- def post(method, params = {},&proc)
+ def post(method, params = {},use_session_key=true,&proc)
add_facebook_params(params, method)
- @session_key && params[:session_key] ||= @session_key
+ use_session_key && @session_key && params[:session_key] ||= @session_key
final_params=params.merge(:sig => signature_for(params))
if batch_request?
add_to_batch(final_params,&proc)
View
@@ -0,0 +1,24 @@
+<fb:fbml>
+ <style>
+ body { background-color: #fff; color: #333; }
+
+ body, p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+ }
+
+ pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px;
+ }
+
+ a { color: #000; }
+ a:visited { color: #666; }
+ a:hover { color: #fff; background-color:#000; }
+ </style>
+
+<%= @contents %>
+
+</fb:fbml>

0 comments on commit a4985c1

Please sign in to comment.