mmangino-facebooker 1.0.31 → 1.0.32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,10 @@
1
+ === HEAD
2
+
3
+ * New Features
4
+
5
+ * Facebooker::User#publish_to for publishing to a Wall or News Stream
6
+ * Optionally parses with Nokogiri. Just require 'nokogiri' in your app.
7
+
1
8
  === 1.0.13 / 2009-02-26
2
9
 
3
10
  * Modified fql_query to return results as Hashes as a last resort [Alan Larkin]
data/facebooker.gemspec CHANGED
@@ -2,17 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{facebooker}
5
- s.version = "1.0.31"
5
+ s.version = "1.0.32"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chad Fowler", "Patrick Ewing", "Mike Mangino", "Shane Vitarana", "Corey Innis"]
9
- s.date = %q{2009-04-30}
10
- s.description = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]. Its goals are:
11
-
12
- * Idiomatic Ruby
13
- * No dependencies outside of the Ruby standard library (This is true with Rails 2.1. Previous Rails versions require the JSON gem)
14
- * Concrete classes and methods modeling the Facebook data, so it's easy for a Rubyist to understand what's available
15
- * Well tested}
9
+ s.date = %q{2009-05-12}
10
+ s.description = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]. Its goals are: * Idiomatic Ruby * No dependencies outside of the Ruby standard library (This is true with Rails 2.1. Previous Rails versions require the JSON gem) * Concrete classes and methods modeling the Facebook data, so it's easy for a Rubyist to understand what's available * Well tested}
16
11
  s.email = %q{mmangino@elevatedrails.com}
17
12
  s.extra_rdoc_files = ["Manifest.txt", "CHANGELOG.rdoc", "COPYING.rdoc", "README.rdoc", "TODO.rdoc"]
18
13
  s.files = [".autotest", "CHANGELOG.rdoc", "COPYING.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "TODO.rdoc", "examples/desktop_login.rb", "facebooker.gemspec", "generators/facebook/facebook_generator.rb", "generators/facebook/templates/config/facebooker.yml", "generators/facebook/templates/public/javascripts/facebooker.js", "generators/facebook_controller/USAGE", "generators/facebook_controller/facebook_controller_generator.rb", "generators/facebook_controller/templates/controller.rb", "generators/facebook_controller/templates/functional_test.rb", "generators/facebook_controller/templates/helper.rb", "generators/facebook_controller/templates/view.fbml.erb", "generators/facebook_controller/templates/view.html.erb", "generators/facebook_publisher/facebook_publisher_generator.rb", "generators/facebook_publisher/templates/create_facebook_templates.rb", "generators/facebook_publisher/templates/publisher.rb", "generators/facebook_scaffold/USAGE", "generators/facebook_scaffold/facebook_scaffold_generator.rb", "generators/facebook_scaffold/templates/controller.rb", "generators/facebook_scaffold/templates/facebook_style.css", "generators/facebook_scaffold/templates/functional_test.rb", "generators/facebook_scaffold/templates/helper.rb", "generators/facebook_scaffold/templates/layout.fbml.erb", "generators/facebook_scaffold/templates/layout.html.erb", "generators/facebook_scaffold/templates/style.css", "generators/facebook_scaffold/templates/view_edit.fbml.erb", "generators/facebook_scaffold/templates/view_edit.html.erb", "generators/facebook_scaffold/templates/view_index.fbml.erb", "generators/facebook_scaffold/templates/view_index.html.erb", "generators/facebook_scaffold/templates/view_new.fbml.erb", "generators/facebook_scaffold/templates/view_new.html.erb", "generators/facebook_scaffold/templates/view_show.fbml.erb", "generators/facebook_scaffold/templates/view_show.html.erb", "generators/publisher/publisher_generator.rb", "generators/xd_receiver/templates/xd_receiver.html", "generators/xd_receiver/xd_receiver_generator.rb", "init.rb", "install.rb", "lib/facebooker.rb", "lib/facebooker/adapters/adapter_base.rb", "lib/facebooker/adapters/bebo_adapter.rb", "lib/facebooker/adapters/facebook_adapter.rb", "lib/facebooker/admin.rb", "lib/facebooker/batch_request.rb", "lib/facebooker/data.rb", "lib/facebooker/feed.rb", "lib/facebooker/logging.rb", "lib/facebooker/mobile.rb", "lib/facebooker/mock/service.rb", "lib/facebooker/mock/session.rb", "lib/facebooker/model.rb", "lib/facebooker/models/affiliation.rb", "lib/facebooker/models/album.rb", "lib/facebooker/models/applicationproperties.rb", "lib/facebooker/models/applicationrestrictions.rb", "lib/facebooker/models/cookie.rb", "lib/facebooker/models/education_info.rb", "lib/facebooker/models/event.rb", "lib/facebooker/models/friend_list.rb", "lib/facebooker/models/group.rb", "lib/facebooker/models/info_item.rb", "lib/facebooker/models/info_section.rb", "lib/facebooker/models/location.rb", "lib/facebooker/models/notifications.rb", "lib/facebooker/models/page.rb", "lib/facebooker/models/photo.rb", "lib/facebooker/models/tag.rb", "lib/facebooker/models/user.rb", "lib/facebooker/models/video.rb", "lib/facebooker/models/work_info.rb", "lib/facebooker/parser.rb", "lib/facebooker/rails/controller.rb", "lib/facebooker/rails/cucumber.rb", "lib/facebooker/rails/cucumber/world.rb", "lib/facebooker/rails/extensions/action_controller.rb", "lib/facebooker/rails/extensions/rack_setup.rb", "lib/facebooker/rails/extensions/routing.rb", "lib/facebooker/rails/facebook_form_builder.rb", "lib/facebooker/rails/facebook_pretty_errors.rb", "lib/facebooker/rails/facebook_request_fix.rb", "lib/facebooker/rails/facebook_session_handling.rb", "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/integration_session.rb", "lib/facebooker/rails/profile_publisher_extensions.rb", "lib/facebooker/rails/publisher.rb", "lib/facebooker/rails/routing.rb", "lib/facebooker/rails/test_helpers.rb", "lib/facebooker/rails/utilities.rb", "lib/facebooker/server_cache.rb", "lib/facebooker/service.rb", "lib/facebooker/session.rb", "lib/facebooker/version.rb", "lib/net/http_multipart_post.rb", "lib/rack/facebook.rb", "lib/tasks/facebooker.rake", "lib/tasks/tunnel.rake", "rails/init.rb", "setup.rb", "templates/layout.erb", "test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/fixtures/multipart_post_body_with_only_parameters.txt", "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/rails_test_helper.rb", "test/test_helper.rb"]
@@ -21,23 +16,23 @@ Gem::Specification.new do |s|
21
16
  s.rdoc_options = ["--main", "README.rdoc"]
22
17
  s.require_paths = ["lib"]
23
18
  s.rubyforge_project = %q{facebooker}
24
- s.rubygems_version = %q{1.3.2}
19
+ s.rubygems_version = %q{1.3.1}
25
20
  s.summary = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]}
26
- s.test_files = ["test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb"]
21
+ s.test_files = ["test/facebooker_test.rb", "test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb"]
27
22
 
28
23
  if s.respond_to? :specification_version then
29
24
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
30
- s.specification_version = 3
25
+ s.specification_version = 2
31
26
 
32
27
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
33
28
  s.add_runtime_dependency(%q<json>, [">= 1.0.0"])
34
- s.add_development_dependency(%q<hoe>, [">= 1.12.1"])
29
+ s.add_development_dependency(%q<hoe>, [">= 1.11.0"])
35
30
  else
36
31
  s.add_dependency(%q<json>, [">= 1.0.0"])
37
- s.add_dependency(%q<hoe>, [">= 1.12.1"])
32
+ s.add_dependency(%q<hoe>, [">= 1.11.0"])
38
33
  end
39
34
  else
40
35
  s.add_dependency(%q<json>, [">= 1.0.0"])
41
- s.add_dependency(%q<hoe>, [">= 1.12.1"])
36
+ s.add_dependency(%q<hoe>, [">= 1.11.0"])
42
37
  end
43
38
  end
@@ -46,9 +46,8 @@ function encodeURIComponent(str) {
46
46
  }
47
47
  };
48
48
 
49
- var Form = {};
50
49
  Form.serialize = function(form_element) {
51
- return $(form_element).serialize();
50
+ return $(form_element).serialize();
52
51
  };
53
52
 
54
53
  Ajax.Updater = function (container,url,options) {
@@ -69,22 +68,7 @@ Ajax.Updater = function (container,url,options) {
69
68
  this.ajax.onerror = options["onFailure"];
70
69
  }
71
70
 
72
- // Yes, this is an excercise in undoing what we just did
73
- // FB doesn't provide encodeURI, but they will encode things passed as a hash
74
- // so we turn it into a string, esaping & and =
75
- // then we split it all back out here
76
- // this could be killed if encodeURIComponent was available
77
- parameters={};
78
- if (options['parameters']) {
79
- pairs=options['parameters'].split('&');
80
- for (var i=0; i<pairs.length; i++) {
81
- kv=pairs[i].split('=');
82
- key=kv[0].replace(/%3D/g,'=').replace(/%26/g,'&');
83
- val=kv[1].replace(/%3D/g,'=').replace(/%26/g,'&');
84
- parameters[key]=val;
85
- }
86
- }
87
- this.ajax.post(url,parameters);
71
+ this.ajax.post(url,options['parameters']);
88
72
  if (options["onLoading"]) {
89
73
  options["onLoading"].call()
90
74
  }
data/install.rb CHANGED
@@ -9,4 +9,4 @@ script = File.join('public', 'javascripts', 'facebooker.js')
9
9
  [config, script].each do |path|
10
10
  FileUtils.cp File.join(templates, path), File.join(RAILS_ROOT, path) unless File.exist?(File.join(RAILS_ROOT, path))
11
11
  end
12
- puts IO.read(File.join(dir, 'README'))
12
+ puts IO.read(File.join(dir, 'README.rdoc'))
@@ -1,14 +1,14 @@
1
1
  module Facebooker
2
2
  class BeboAdapter < AdapterBase
3
-
3
+
4
4
  def canvas_server_base
5
5
  "apps.bebo.com"
6
6
  end
7
-
7
+
8
8
  def api_server_base
9
9
  'apps.bebo.com'
10
10
  end
11
-
11
+
12
12
  def api_rest_path
13
13
  "/restserver.php"
14
14
  end
@@ -44,9 +44,9 @@ module Facebooker
44
44
  end
45
45
  alias_method :set_profile_fbml_without_bebo_adapter, :set_profile_fbml
46
46
  alias_method :set_profile_fbml, :set_profile_fbml_with_bebo_adapter
47
-
47
+
48
48
  private
49
-
49
+
50
50
  BEBO_FIELDS = FIELDS - [:meeting_sex, :wall_count, :meeting_for]
51
51
 
52
52
  remove_method :collect
@@ -57,15 +57,15 @@ module Facebooker
57
57
  else
58
58
  FIELDS.reject{|field_name| !fields.empty? && !fields.include?(field_name)}.join(',')
59
59
  end
60
- end
60
+ end
61
61
  end
62
-
63
-
62
+
63
+
64
64
  class PublishTemplatizedAction < Parser#:nodoc:
65
65
  class <<self
66
66
  def process_with_bebo_adapter(data)
67
67
  if(Facebooker.is_for?(:bebo))
68
- element('feed_publishTemplatizedAction_response', data).text_value
68
+ element('feed_publishTemplatizedAction_response', data).content
69
69
  else
70
70
  process_without_bebo_adapter(data)
71
71
  end
@@ -3,7 +3,7 @@ module Facebooker
3
3
  def initialize(session)
4
4
  @session = session
5
5
  end
6
-
6
+
7
7
  ##
8
8
  # ** BETA ***
9
9
  # Sets a cookie on Facebook
@@ -11,32 +11,32 @@ module Facebooker
11
11
  # +name+ Name of the cookie
12
12
  # +value+ Value of the cookie
13
13
  # Optional:
14
- # +expires+ Time when the cookie should expire. If not specified, the cookie never expires.
14
+ # +expires+ Time when the cookie should expire. If not specified, the cookie never expires.
15
15
  # +path+ Path relative to the application's callback URL, with which the cookie should be associated. (default value is /?
16
16
  def set_cookie(user, name, value, expires=nil, path=nil)
17
- @session.post('facebook.data.setCookie',
18
- :uid => User.cast_to_facebook_id(user),
19
- :name => name,
20
- :value => value,
21
- :expires => expires,
17
+ @session.post('facebook.data.setCookie',
18
+ :uid => User.cast_to_facebook_id(user),
19
+ :name => name,
20
+ :value => value,
21
+ :expires => expires,
22
22
  :path => path) {|response| response == '1'}
23
23
  end
24
-
24
+
25
25
  ##
26
26
  # ** BETA ***
27
27
  # Gets a cookie stored on Facebook
28
- # +user+ The user from whom to get the cookies.
29
- # Optional:
28
+ # +user+ The user from whom to get the cookies.
29
+ # Optional:
30
30
  # +name+ The name of the cookie. If not specified, all the cookies for the given user get returned.
31
31
  def get_cookies(user, name=nil)
32
- @cookies = @session.post(
32
+ @cookies = @session.post(
33
33
  'facebook.data.getCookies', :uid => User.cast_to_facebook_id(user), :name => name) do |response|
34
34
  response.map do |hash|
35
35
  Cookie.from_hash(hash)
36
36
  end
37
37
  end
38
- end
39
-
38
+ end
39
+
40
40
  ##
41
41
  # ** BETA ***
42
42
  # Gets a preference stored on Facebook
@@ -54,4 +54,4 @@ module Facebooker
54
54
  @session.post('facebook.data.setUserPreference', :pref_id=>pref_id, :value=>value)
55
55
  end
56
56
  end
57
- end
57
+ end
@@ -69,47 +69,75 @@ module Facebooker
69
69
  # Set the list of friends, given an array of User objects. If the list has been retrieved previously, will not set
70
70
  def friends=(list_of_friends,flid=nil)
71
71
  @friends_hash ||= {}
72
- flid=cast_to_friend_list_id(flid)
73
- #use __blank instead of nil so that this is cached
74
- cache_key = flid||"__blank"
75
-
72
+ flid=cast_to_friend_list_id(flid)
73
+ #use __blank instead of nil so that this is cached
74
+ cache_key = flid||"__blank"
75
+
76
76
  @friends_hash[cache_key] ||= list_of_friends
77
77
  end
78
78
 
79
79
  def cast_to_friend_list_id(flid)
80
80
  case flid
81
- when String
82
- list=friend_lists.detect {|f| f.name==flid}
83
- raise Facebooker::Session::InvalidFriendList unless list
84
- list.flid
85
- when FriendList
86
- flid.flid
87
- else
88
- flid
89
- end
90
- end
81
+ when String
82
+ list=friend_lists.detect {|f| f.name==flid}
83
+ raise Facebooker::Session::InvalidFriendList unless list
84
+ list.flid
85
+ when FriendList
86
+ flid.flid
87
+ else
88
+ flid
89
+ end
90
+ end
91
91
  ##
92
92
  # Retrieve friends
93
93
  def friends(flid = nil)
94
- @friends_hash ||= {}
95
- flid=cast_to_friend_list_id(flid)
96
-
97
- #use __blank instead of nil so that this is cached
98
- cache_key = flid||"__blank"
99
- options = {:uid=>self.id}
100
- options[:flid] = flid unless flid.nil?
101
- @friends_hash[cache_key] ||= @session.post('facebook.friends.get', options,false).map do |uid|
94
+ @friends_hash ||= {}
95
+ flid=cast_to_friend_list_id(flid)
96
+
97
+ #use __blank instead of nil so that this is cached
98
+ cache_key = flid||"__blank"
99
+ options = {:uid=>self.id}
100
+ options[:flid] = flid unless flid.nil?
101
+ @friends_hash[cache_key] ||= @session.post('facebook.friends.get', options,false).map do |uid|
102
102
  User.new(uid, @session)
103
103
  end
104
104
  @friends_hash[cache_key]
105
105
  end
106
-
107
- def friend_lists
106
+
107
+ ###
108
+ # Publish a post into the stream on the user's Wall and News Feed. This
109
+ # post also appears in the user's friend's streams. The +publish_stream+
110
+ # extended permission must be granted in order to use this method.
111
+ #
112
+ # See: http://wiki.developers.facebook.com/index.php/Stream.publish
113
+ #
114
+ # +target+ can be the current user or some other user.
115
+ #
116
+ # Example:
117
+ # # Publish a message to my own wall:
118
+ # me.publish_to(me, :message => 'hello world')
119
+ #
120
+ # # Publish to a friend's wall with an action link:
121
+ # me.publish_to(my_friend, :message => 'how are you?', :action_links => [
122
+ # :text => 'my website',
123
+ # :href => 'http://tenderlovemaking.com/'
124
+ # ])
125
+ def publish_to target, options = {}
126
+ @session.post('facebook.stream.publish',
127
+ :uid => self.id,
128
+ :target_id => target.id,
129
+ :message => options[:message],
130
+ :attachment => options[:attachment],
131
+ :action_links => options[:action_links]
132
+ )
133
+ end
134
+
135
+ def friend_lists
108
136
  @friend_lists ||= @session.post('facebook.friends.getLists').map do |hash|
109
- friend_list = FriendList.from_hash(hash)
110
- friend_list.session = session
111
- friend_list
112
- end
137
+ friend_list = FriendList.from_hash(hash)
138
+ friend_list.session = session
139
+ friend_list
140
+ end
113
141
  end
114
142
  ###
115
143
  # Retrieve friends with user info populated