Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mmangino/facebooker
Browse files Browse the repository at this point in the history
* 'master' of github.com:mmangino/facebooker: (46 commits)
  Bump version
  facebook.stream.get for some viewer.
  a helpful note
  got the rest of the tests
  Added change
  new parser for weird xml in dashboard apis
  more comprehensive tests for dashboard api changes
  news and some activity
  Support for new dashboard counter APIs, removed logger from fb_connect.rb
  Added support for the method "facebook.users.IsAppUser", via User#app_user?
  Support for methods 'facebook.comments.add','facebook.comments.remove', and 'facebook.comments.get'.
  fix path to facebooker.yml for Rake facebooker:setup task
  Support for method 'facebook.message.getThreadsInFolder', and 'read_mailbox' extended permission.
  Added #page_url to the attr_accessor section of Facebooker::Page
  Revert "Add page_url to pages"
  Add page_url to pages
  Change redirect to accept status, but ignore it
  Alias Page#page_id as Page#id
  Updating facebook ssl url per fb documentation
  Add comment to rack setup
  ...
  • Loading branch information
tenderlove committed Feb 27, 2010
2 parents 65469d1 + 62a5f53 commit f1ac184
Show file tree
Hide file tree
Showing 31 changed files with 1,705 additions and 60 deletions.
6 changes: 6 additions & 0 deletions Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ lib/facebooker/models/album.rb
lib/facebooker/models/applicationproperties.rb
lib/facebooker/models/applicationrestrictions.rb
lib/facebooker/models/cookie.rb
lib/facebooker/models/comment.rb
lib/facebooker/models/education_info.rb
lib/facebooker/models/event.rb
lib/facebooker/models/family_relative_info.rb
Expand All @@ -78,6 +79,7 @@ lib/facebooker/models/tag.rb
lib/facebooker/models/user.rb
lib/facebooker/models/video.rb
lib/facebooker/models/work_info.rb
lib/facebooker/models/message_thread.rb
lib/facebooker/parser.rb
lib/facebooker/rails/backwards_compatible_param_checks.rb
lib/facebooker/rails/controller.rb
Expand All @@ -95,6 +97,7 @@ lib/facebooker/rails/facebook_url_helper.rb
lib/facebooker/rails/facebook_url_rewriting.rb
lib/facebooker/rails/helpers.rb
lib/facebooker/rails/helpers/fb_connect.rb
lib/facebooker/rails/helpers/stream_publish.rb
lib/facebooker/rails/integration_session.rb
lib/facebooker/rails/profile_publisher_extensions.rb
lib/facebooker/rails/publisher.rb
Expand All @@ -113,7 +116,9 @@ lib/facebooker/stream_post.rb
lib/facebooker/version.rb
lib/net/http_multipart_post.rb
lib/rack/facebook.rb
lib/rack/facebook_session.rb
lib/tasks/facebooker.rake
lib/tasks/facebooker.rb
lib/tasks/tunnel.rake
rails/init.rb
setup.rb
Expand Down Expand Up @@ -142,5 +147,6 @@ test/fixtures/multipart_post_body_with_single_file.txt
test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt
test/net/http_multipart_post_test.rb
test/rack/facebook_test.rb
test/rack/facebook_session_test.rb
test/rails_test_helper.rb
test/test_helper.rb
6 changes: 6 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ Facebooker can be installed as a Rails plugin by:

If you don't have git, the plugin can be downloaded from http://github.com/mmangino/facebooker/tarball/master

=== Using Gem in Rails

The rake task would not be added automatically, so to use it in rails you would have to add the following towards the end of your Rakefile:

require 'tasks/facebooker'

Once the plugin is installed, you will need to configure your Facebook app in config/facebooker.yml.

Your application users will need to have added the application in facebook to access all of facebooker's features. You enforce this by adding
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ HOE = Hoe.spec('facebooker') do
self.history_file = 'CHANGELOG.rdoc'
self.remote_rdoc_dir = '' # Release to root
self.test_globs = ['test/**/*_test.rb']
extra_deps << ['json', '>= 1.0.0']
extra_deps << ['json_pure', '>= 1.0.0']
self.extra_rdoc_files = FileList['*.rdoc']
end

Expand Down
22 changes: 11 additions & 11 deletions facebooker.gemspec

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generators/xd_receiver/templates/xd_receiver_ssl.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<title>Cross-Domain Receiver Page</title>
</head>
<body>
<script src="https://www.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script>
<script src="https://ssl.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script>
</body>
</html>
9 changes: 8 additions & 1 deletion lib/facebooker.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
unless defined?(ActiveSupport) and defined?(ActiveSupport::JSON)
require 'json'
begin
require 'json'
rescue LoadError
gem "json_pure"
require "json"
end
module Facebooker
def self.json_decode(str)
JSON.parse(str)
Expand Down Expand Up @@ -233,6 +238,7 @@ def request_for_canvas(is_canvas_request)
require 'facebooker/models/location'
require 'facebooker/models/affiliation'
require 'facebooker/models/album'
require 'facebooker/models/comment'
require 'facebooker/models/education_info'
require 'facebooker/models/work_info'
require 'facebooker/models/event'
Expand All @@ -249,6 +255,7 @@ def request_for_canvas(is_canvas_request)
require 'facebooker/models/info_section'
require 'facebooker/models/friend_list'
require 'facebooker/models/video'
require 'facebooker/models/message_thread'
require 'facebooker/adapters/adapter_base'
require 'facebooker/adapters/facebook_adapter'
require 'facebooker/adapters/bebo_adapter'
24 changes: 24 additions & 0 deletions lib/facebooker/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,29 @@ def initialize(session)
def get_public_info(properties)
(@session.post 'facebook.application.getPublicInfo', properties)
end

# facebook_session.application.add_global_news [{ :message => 'Hi all users', :action_link => { :text => "Hi application", :href => 'http://facebook.er/' }}], 'http://facebook.er/icon.png'
def add_global_news(news, image=nil)
params = {}
params[:news] = news
params[:image] = image if image
@session.post('facebook.dashboard.addGlobalNews', params)
end

# currently bugged on Facebook; returns all
# facebook_session.application.get_global_news '310354202543'
def get_global_news(*news_ids)
params = {}
params[:news_ids] = news_ids.flatten if news_ids
@session.post('facebook.dashboard.getGlobalNews', params)
end

# facebook_session.application.clear_global_news '310354202543'
def clear_global_news(*news_ids)
params = {}
params[:news_ids] = news_ids.flatten if news_ids
@session.post('facebook.dashboard.clearGlobalNews', params)
end

end
end
9 changes: 9 additions & 0 deletions lib/facebooker/models/comment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'facebooker/model'
module Facebooker
##
# A simple representation of a comment
class Comment
include Model
attr_accessor :xid, :fromid, :time, :text, :id
end
end
89 changes: 89 additions & 0 deletions lib/facebooker/models/message_thread.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
require 'facebooker/model'
module Facebooker
class MessageThread
include Model

id_is :thread_id
attr_accessor :subject, :updated_time, :recipients
attr_accessor :parent_message_id, :parent_thread_id, :message_count
attr_accessor :snippet, :snippet_author, :object_id, :unread

class Message
include Model

attr_accessor :message_id, :author_id, :body, :created_time, :attachment, :thread_id

# An attachment can be a photo, a video, or a link
class Attachment
include Model

attr_accessor :name, :href, :icon, :caption, :description

# The Facebook messages API is in beta, this helper method is supposed to fail anytime soon
def video?
self.href =~ /\Ahttp:\/\/www\.facebook\.com\/video\/video\.php.*/
end

# The Facebook messages API is in beta, this helper method is supposed to fail anytime soon
def photo?
self.href =~ /\Ahttp:\/\/www\.facebook\.com\/photo\.php.*/
end

# The Facebook messages API is in beta, this helper method is supposed to fail anytime soon
def link?
!video? && !photo?
end
end
hash_settable_accessor :attachment, Facebooker::MessageThread::Message::Attachment
end
hash_settable_list_accessor :messages, Facebooker::MessageThread::Message

end
end

# Example of attachments

# -- Photo --

# <attachment>
# <media list="true"/>
# <href>http://www.facebook.com/photo.php?pid=12345&amp;id=54321</href>
# <properties list="true"/>
# <icon>http://b.static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif</icon>
# <fb_object_type/>
# <fb_object_id/>
# <tagged_ids list="true"/>
# </attachment>

# -- Webcam video --

# <attachment>
# <media list="true"/>
# <name>Feb 10, 2010 1:26pm</name>
# <href>http://www.facebook.com/video/video.php?v=12345</href>
# <properties list="true"/>
# <icon>http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif</icon>
# <fb_object_type/>
# <fb_object_id/>
# <tagged_ids list="true"/>
# </attachment>

# -- Link --

# <attachment>
# <media list="true">
# <stream_media>
# <href>http://www.facebook.com/l.php?u=http%253A%252F%252Fwww.google.fr%252F&amp;h=e46dd63cdbfadb74958fbe44e98f339c</href>
# <type>link</type>
# <src>http://external.ak.fbcdn.net/safe_image.php?d=dd54bba6b6e6479a89bb8084573c02c8&amp;w=90&amp;h=90&amp;url=http%3A%2F%2Fwww.google.fr%2Fintl%2Ffr_fr%2Fimages%2Flogo.gif</src>
# </stream_media>
# </media>
# <name>Google</name>
# <href>http://www.facebook.com/l.php?u=http%253A%252F%252Fwww.google.fr%252F&amp;h=e46dd63cdbfadb74958fbe44e98f339c</href>
# <caption>www.google.fr</caption>
# <properties list="true"/>
# <icon>http://b.static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif</icon>
# <fb_object_type/>
# <fb_object_id/>
# <tagged_ids list="true"/>
# </attachment>
6 changes: 4 additions & 2 deletions lib/facebooker/models/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ def initialize(*args)
end

include Model
attr_accessor :page_id,:name,:pic_small,:pic_big,:pic_square,:pic,:pic_large,:type,:website,:has_added_app,:founded,:company_overview,:mission,:products,:location,:parking,:public_transit,:hours,:attire,:payment_options,:culinary_team,:general_manager,:price_range,:restaurant_services,:restaurant_specialties,:release_date,:genre,:starring,:screenplay_by,:directed_by,:produced_by,:studio,:awards,:plot_outline,:network,:season,:schedule,:written_by,:band_members,:hometown,:current_location,:record_label,:booking_agent,:artists_we_like,:influences,:band_interests,:bio,:affiliation,:birthday,:personal_info,:personal_interests,:members,:built,:features,:mpg,:general_info,:fan_count
attr_accessor :page_id,:name,:pic_small,:pic_big,:pic_square,:pic,:pic_large,:type,:website,:has_added_app,:founded,:company_overview,:mission,:products,:location,:parking,:public_transit,:hours,:attire,:payment_options,:culinary_team,:general_manager,:price_range,:restaurant_services,:restaurant_specialties,:release_date,:genre,:starring,:screenplay_by,:directed_by,:produced_by,:studio,:awards,:plot_outline,:network,:season,:schedule,:written_by,:band_members,:hometown,:current_location,:record_label,:booking_agent,:artists_we_like,:influences,:band_interests,:bio,:affiliation,:birthday,:personal_info,:personal_interests,:members,:built,:features,:mpg,:general_info,:fan_count,:page_url
attr_reader :genre


alias_method :id, :page_id

def genre=(value)
@genre = value.kind_of?(Hash) ? Genre.from_hash(value) : value
end
Expand Down
Loading

0 comments on commit f1ac184

Please sign in to comment.