RFb 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,98 @@
1
1
  # RFb
2
2
 
3
- *RubyFacebook* - interact with Facebook REST API (json) - rails3 enabled
3
+ **RubyFacebook** - interact with Facebook REST API (json) - rails3 enabled
4
+
5
+ Share datas with Facebook via JSON with RFb! No XML to deal with, no parsers needed, reduced verbosity, increased happiness. Ruby1.9 required.
4
6
 
5
7
 
6
8
  ## Installation
7
9
 
8
- ## Usage
10
+ gem install RFb
11
+
12
+
13
+ ## Bundling
14
+
15
+ to bundle RFb, in your Gemfile:
16
+
17
+ gem 'RFb', :require => 'r_fb'
18
+
19
+
20
+ ## Configuration
21
+
22
+ configurations in yml file soon will come...
23
+
24
+
25
+ ### Rails 3
26
+
27
+ - add RFb to your Gemfile
28
+ - install it (bundle install)
29
+ - create a new initializer file (say 'facebook.rb') and add some configurations:
30
+
31
+ config/initializers/facebook.rb :
32
+
33
+ require 'r_fb'
34
+
35
+ RFb.app_name = "your_app_name"
36
+ RFb.environment = Rails.env
37
+ RFb.api_key = {
38
+ development: "your_facebook_api_key_here",
39
+ test: "",
40
+ production: ""
41
+ }
42
+ RFb.secret_key = {
43
+ development: "your_facebook_secret_here",
44
+ test: "",
45
+ production: ""
46
+ }
47
+ RFb.debug = true # displays
48
+
49
+
50
+
51
+ and you're done!
52
+
53
+
54
+
55
+ ## Basic Usage
56
+
57
+ See the facebook REST API ( http://wiki.developers.facebook.com/index.php/API ) so you can see what methods are available and how to call them.
58
+
59
+
60
+ *Example:*
61
+
62
+ To get some user information:
63
+
64
+ fields = %w(username name first_name has_added_app locale pic profile_url status timezone)
65
+ RFb.request({
66
+ method: "facebook.Users.getInfo",
67
+ uids: [1218562195].to_s,
68
+ fields: [fields].to_s
69
+ })
70
+
71
+ result:
72
+
73
+ [{"first_name":"Francesco","name":"Francesco Canessa","pic":"http:\/\/profile.ak.fbcdn.net\/v22940\/158\/98\/s1218562195_9493.jpg","status":{"message":"","time":0,"status_id":0},"timezone":1,"uid":1218562195,"has_added_app":true,"locale":"en_US","profile_url":"http:\/\/www.facebook.com\/makevoid","username":"makevoid"}]
74
+
75
+
76
+ a shorter version:
77
+
78
+ User.new(fb_id: 1218562195)
79
+
80
+
81
+
82
+ # Setup sessions
83
+
84
+ build better rails3 controllers-model api and document... I'll create an example project
85
+
86
+ ## Getting friends
87
+
88
+ RFb::User.new(fb_id: @current_user.fb_id).friends
89
+
90
+ result (an array of users properties):
91
+
92
+ [{"current_location"=>{"city"=>"Buffalo", "state"=>"New York", "country"=>"United States", "zip"=>"14623"}, "first_name"=>"Ali", "name"=>"Ali Babloo", "pic"=>"http://profile.ak.fbcdn.net/v230/1615/8/s1027654249_4327.jpg", "status"=>{"message"=>"", "time"=>0, "status_id"=>0}, "timezone"=>-8, "has_added_app"=>true, "locale"=>"en_US", "profile_url"=>"http://www.facebook.com/dark14horse", "username"=>"dark14horse"}, {..........}, {...}]
9
93
 
94
+ more docs will come when session handling API will be solid enough!
95
+
96
+
10
97
 
11
- yes.. documentation will come....
98
+ Look at the source code and see that is pretty simple stuff, so fork it, change it, get inspired and roll your own... simply do whatever you want!
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{RFb}
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Francesco 'makevoid' Canessa"]
12
- s.date = %q{2010-02-11}
12
+ s.date = %q{2010-02-17}
13
13
  s.description = %q{RubyFacebook interacts with Facebook REST API via JSON. No XML to deal with, no parsers needed, reduced verbosity, increased happiness. Ruby1.9 required. Fork it, please!}
14
14
  s.email = %q{makevoid@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "lib/r_fb/exceptions.rb",
28
28
  "lib/r_fb/fql.rb",
29
29
  "lib/r_fb/methods.rb",
30
+ "lib/r_fb/notification.rb",
30
31
  "lib/r_fb/parser.rb",
31
32
  "lib/r_fb/session.rb",
32
33
  "lib/r_fb/user.rb"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -3,14 +3,15 @@ require 'net/http'
3
3
  require 'json'
4
4
 
5
5
  module RFb
6
- @@path = "r_fb"#File.expand_path("../r_fb", __FILE__)
7
- require "#{@@path}/exceptions"
8
- require "#{@@path}/configurable"
9
- require "#{@@path}/fql"
10
- require "#{@@path}/methods"
11
- require "#{@@path}/parser"
12
- require "#{@@path}/session"
13
- require "#{@@path}/user"
6
+ PATH = "r_fb"
7
+ #PATH = File.expand_path("../r_fb", __FILE__)
8
+ require "#{PATH}/exceptions"
9
+ require "#{PATH}/configurable"
10
+ require "#{PATH}/fql"
11
+ require "#{PATH}/methods"
12
+ require "#{PATH}/parser"
13
+ require "#{PATH}/session"
14
+ require "#{PATH}/user"
14
15
 
15
16
  SERVER = "www.facebook.com"
16
17
  API_PATH = "#{SERVER}/restserver.php"
@@ -0,0 +1,14 @@
1
+ module RFb
2
+ class Notification
3
+
4
+ INVITE = "Sell your things to your friends and other facebook users. <fb:req-choice url='http://apps.facebook.com/alibazaar/' label='Add Ali Bazaar' />"
5
+
6
+ # usage:
7
+ # Notification.send(to_ids: recipients_ids, notification: RFB::Notification::INVITE)
8
+ #
9
+ # to_ids: recipients_ids, notification: "fbml and html allowed"
10
+ def send(opts)
11
+ RFb.request(opts)
12
+ end
13
+ end
14
+ end
@@ -4,11 +4,14 @@ module RFb
4
4
  attr_accessor :params
5
5
  def initialize(params={})
6
6
  @params = filter_session_params(params)
7
- @@session_key = params["fb_sig_session_key"]
7
+ @@rfb_session_key = params["fb_sig_session_key"]
8
8
  end
9
9
 
10
10
  def self.session_key
11
- @@session_key
11
+ @@rfb_session_key
12
+ end
13
+ def self.session_key=(ses)
14
+ @@rfb_session_key = ses
12
15
  end
13
16
 
14
17
  def logged_in?
@@ -6,6 +6,7 @@ module RFb
6
6
 
7
7
  attr_accessor :fb_id
8
8
  attr_accessor :user
9
+ attr_accessor :session
9
10
  FIELDS.map do |field|
10
11
  attr_accessor field
11
12
  end
@@ -16,6 +17,8 @@ module RFb
16
17
  end
17
18
  @user = attrs[:user]
18
19
  @fb_id = attrs[:fb_id]
20
+ @session = attrs[:session]
21
+ Session.session_key = @session unless @session.nil?
19
22
  end
20
23
 
21
24
  def self.first(attrs={})
@@ -32,8 +35,13 @@ module RFb
32
35
  u = User.new(attrs.merge(:user => user)).select_all
33
36
  end
34
37
 
38
+ # use FIELDS.join(", ") instead of uid to select other datas
35
39
  def friends
36
- Fql.query("SELECT #{FIELDS.join(", ")} FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=#{self.fb_id}) AND has_added_app = 1 ")
40
+ Fql.query("SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=#{self.fb_id}) AND has_added_app = 1")
41
+ end
42
+
43
+ def friends_nonapp(limit=true)
44
+ Fql.query("SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=#{self.fb_id}) AND has_added_app = 0#{" LIMIT 30" if limit}")
37
45
  end
38
46
 
39
47
  def is_app_user?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RFb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco 'makevoid' Canessa
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-11 00:00:00 +01:00
12
+ date: 2010-02-17 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -33,6 +33,7 @@ files:
33
33
  - lib/r_fb/exceptions.rb
34
34
  - lib/r_fb/fql.rb
35
35
  - lib/r_fb/methods.rb
36
+ - lib/r_fb/notification.rb
36
37
  - lib/r_fb/parser.rb
37
38
  - lib/r_fb/session.rb
38
39
  - lib/r_fb/user.rb