mini_fb 0.1.11 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +31 -0
- data/lib/mini_fb.rb +11 -8
- metadata +12 -5
data/README.markdown
CHANGED
@@ -26,6 +26,10 @@ Get a MiniFB::Session:
|
|
26
26
|
|
27
27
|
@fb = MiniFB::Session.new(FB_API_KEY, FB_SECRET, @fb_session, @fb_uid)
|
28
28
|
|
29
|
+
Then it makes it a bit easier to use call for a particular user/session.
|
30
|
+
|
31
|
+
response = @fb.calls("stream.get")
|
32
|
+
|
29
33
|
With the session, you can then get the user information for the session/uid.
|
30
34
|
|
31
35
|
user = @fb.user
|
@@ -42,6 +46,33 @@ Or if you want other photos, try:
|
|
42
46
|
|
43
47
|
photos = @fb.photos("pids"=>[12343243,920382343,9208348])
|
44
48
|
|
49
|
+
Facebook Connect
|
50
|
+
----------------
|
51
|
+
|
52
|
+
This is actually very easy, first follow these instructions: http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your_Site
|
53
|
+
|
54
|
+
Then add the following script to the page where you put the login button so it looks like this:
|
55
|
+
|
56
|
+
<script>
|
57
|
+
function facebook_onlogin(){
|
58
|
+
document.location.href = "<%= url_for :action=>"fb_connect" %>";
|
59
|
+
}
|
60
|
+
</script>
|
61
|
+
<fb:login-button onlogin="facebook_onlogin();"></fb:login-button>
|
62
|
+
|
63
|
+
Define an fb_connect method in your login/sessions controller like so:
|
64
|
+
|
65
|
+
def fb_connect
|
66
|
+
@fb_uid = cookies[FB_API_KEY + "_user"]
|
67
|
+
@fb_session = cookies[FB_API_KEY + "_session_key"]
|
68
|
+
puts "uid=#{@fb_uid}"
|
69
|
+
puts "session=#{@fb_session}"
|
70
|
+
|
71
|
+
# And here you would create the user if it doesn't already exist, then redirect them to wherever you want.
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
45
76
|
Support
|
46
77
|
--------
|
47
78
|
|
data/lib/mini_fb.rb
CHANGED
@@ -10,11 +10,11 @@ module MiniFB
|
|
10
10
|
|
11
11
|
@@logging = false
|
12
12
|
|
13
|
-
def enable_logging
|
13
|
+
def self.enable_logging
|
14
14
|
@@logging = true
|
15
15
|
end
|
16
16
|
|
17
|
-
def disable_logging
|
17
|
+
def self.disable_logging
|
18
18
|
@@logging = false
|
19
19
|
end
|
20
20
|
|
@@ -55,8 +55,8 @@ module MiniFB
|
|
55
55
|
|
56
56
|
end
|
57
57
|
class User
|
58
|
-
FIELDS = [:uid, :status, :political, :pic_small, :name, :quotes, :is_app_user, :tv, :profile_update_time, :meeting_sex, :hs_info, :timezone, :relationship_status, :hometown_location, :about_me, :wall_count, :significant_other_id, :pic_big, :music, :work_history, :sex, :religion, :notes_count, :activities, :pic_square, :movies, :has_added_app, :education_history, :birthday, :birthday_date, :first_name, :meeting_for, :last_name, :interests, :current_location, :pic, :books, :affiliations, :locale, :profile_url, :proxied_email, :email_hashes, :allowed_restrictions, :pic_with_logo, :pic_big_with_logo, :pic_small_with_logo, :pic_square_with_logo]
|
59
|
-
STANDARD_FIELDS = [:uid, :first_name, :last_name, :name, :timezone, :birthday, :sex, :affiliations, :locale, :profile_url, :proxied_email]
|
58
|
+
FIELDS = [:uid, :status, :political, :pic_small, :name, :quotes, :is_app_user, :tv, :profile_update_time, :meeting_sex, :hs_info, :timezone, :relationship_status, :hometown_location, :about_me, :wall_count, :significant_other_id, :pic_big, :music, :work_history, :sex, :religion, :notes_count, :activities, :pic_square, :movies, :has_added_app, :education_history, :birthday, :birthday_date, :first_name, :meeting_for, :last_name, :interests, :current_location, :pic, :books, :affiliations, :locale, :profile_url, :proxied_email, :email, :email_hashes, :allowed_restrictions, :pic_with_logo, :pic_big_with_logo, :pic_small_with_logo, :pic_square_with_logo]
|
59
|
+
STANDARD_FIELDS = [:uid, :first_name, :last_name, :name, :timezone, :birthday, :sex, :affiliations, :locale, :profile_url, :proxied_email, :email]
|
60
60
|
|
61
61
|
def self.all_fields
|
62
62
|
FIELDS.join(",")
|
@@ -111,7 +111,7 @@ module MiniFB
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
BAD_JSON_METHODS = ["users.
|
114
|
+
BAD_JSON_METHODS = ["users.getloggedinuser", "auth.promotesession", "users.hasapppermission", "Auth.revokeExtendedPermission"].collect { |x| x.downcase }
|
115
115
|
|
116
116
|
# Call facebook server with a method request. Most keyword arguments
|
117
117
|
# are passed directly to the server with a few exceptions.
|
@@ -132,7 +132,7 @@ module MiniFB
|
|
132
132
|
# to hide value from simple introspection.
|
133
133
|
def MiniFB.call( api_key, secret, method, kwargs )
|
134
134
|
|
135
|
-
puts 'kwargs=' + kwargs.inspect
|
135
|
+
puts 'kwargs=' + kwargs.inspect if @@logging
|
136
136
|
|
137
137
|
if secret.is_a? String
|
138
138
|
secret = FaceBookSecret.new(secret)
|
@@ -168,18 +168,21 @@ module MiniFB
|
|
168
168
|
# Handle response
|
169
169
|
return response.body if custom_format
|
170
170
|
|
171
|
-
fb_method = kwargs["method"]
|
171
|
+
fb_method = kwargs["method"].downcase
|
172
172
|
body = response.body
|
173
173
|
|
174
|
+
puts 'response=' + body.inspect if @@logging
|
174
175
|
begin
|
175
176
|
data = JSON.parse( body )
|
176
|
-
puts 'response=' + data.inspect if @@logging
|
177
177
|
if data.include?( "error_msg" ) then
|
178
178
|
raise FaceBookError.new( data["error_code"] || 1, data["error_msg"] )
|
179
179
|
end
|
180
180
|
|
181
181
|
rescue JSON::ParserError => ex
|
182
182
|
if BAD_JSON_METHODS.include?(fb_method) # Little hack because this response isn't valid JSON
|
183
|
+
if body == "0" || body == "false"
|
184
|
+
return false
|
185
|
+
end
|
183
186
|
return body
|
184
187
|
else
|
185
188
|
raise ex
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_fb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Travis Reeder
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2010-
|
18
|
+
date: 2010-02-22 00:00:00 -08:00
|
14
19
|
default_executable:
|
15
20
|
dependencies: []
|
16
21
|
|
@@ -38,18 +43,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
43
|
requirements:
|
39
44
|
- - ">="
|
40
45
|
- !ruby/object:Gem::Version
|
46
|
+
segments:
|
47
|
+
- 0
|
41
48
|
version: "0"
|
42
|
-
version:
|
43
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - ">="
|
46
52
|
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
47
55
|
version: "0"
|
48
|
-
version:
|
49
56
|
requirements: []
|
50
57
|
|
51
58
|
rubyforge_project:
|
52
|
-
rubygems_version: 1.3.
|
59
|
+
rubygems_version: 1.3.6
|
53
60
|
signing_key:
|
54
61
|
specification_version: 3
|
55
62
|
summary: Tiny facebook library
|