mosaic-facebook 1.3.0 → 1.3.1
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.md +93 -0
- data/lib/mosaic/facebook/graph/event.rb +1 -2
- data/lib/mosaic/facebook/graph/post.rb +1 -1
- data/lib/mosaic/facebook/version.rb +1 -1
- metadata +30 -36
- checksums.yaml +0 -15
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
#Mosaic Facebook API gem
|
2
|
+
|
3
|
+
This gem is designed to make integrating a Facebook application easy into your ruby program.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
If using Bundler, just add it to your Gemfile
|
9
|
+
|
10
|
+
gem 'mosaic-facebook'
|
11
|
+
|
12
|
+
If you want to use it from other applications, just install it as a gem, then require it like normal.
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
For almost any use case of the application, you will want to instantiate a new Facebook Application object.
|
17
|
+
|
18
|
+
app = Mosaic::Facebook::Graph::Application.new(:id => FB_CONFIG["client_id"], :secret => FB_CONFIG["client_secret"])
|
19
|
+
|
20
|
+
You will then want to retrieve the oauth access token to allow you to make authenticated calls to the API.
|
21
|
+
|
22
|
+
@access_token = app.access_token
|
23
|
+
|
24
|
+
### Logging a user in with Facebook
|
25
|
+
|
26
|
+
To start with, you will want to redirect the user to the Facebook authentication page in your controller.
|
27
|
+
|
28
|
+
facebook_client_id = ** your facebook client id **
|
29
|
+
redirect_uri = ** the place where Facebook will redirect them back **
|
30
|
+
scope = ** the permissions you are asking for, comma separated string ***
|
31
|
+
redirect_to "http://www.facebook.com/dialog/oauth?client_id=#{facebook_client_id}&redirect_uri=#{CGI::escape(redirect_uri)}&scope=#{scope}"
|
32
|
+
|
33
|
+
They will then be prompted to authorize your application with your permissions, and be redirected back to your redirect URI. You want to then verify that this was a
|
34
|
+
valid callback, by using the authorize method on the application
|
35
|
+
|
36
|
+
user = app.authorize(params[:code], redirect_uri)
|
37
|
+
|
38
|
+
This call will return a Mosaic::Facebook::Graph::User object, containing the details of the user. For an example call:
|
39
|
+
|
40
|
+
user.name # returns the name of the user
|
41
|
+
user.birthday # returns the user's birthday.
|
42
|
+
|
43
|
+
You can also examine meta-data about a user:
|
44
|
+
|
45
|
+
user.likes # returns all the information about the likes of a user.
|
46
|
+
|
47
|
+
### Checking that a user has liked your facebook page
|
48
|
+
|
49
|
+
Alternately, you can query the like model directly, if you want to find out if a user liked a page
|
50
|
+
|
51
|
+
page_id = ** your facebook page id **
|
52
|
+
Mosaic::Facebook::Graph::Like.find_by_id(user.facebook_id, page_id, :access_token => user.oauth_token).any?
|
53
|
+
|
54
|
+
### Grabbing a list of all the posts for a page
|
55
|
+
|
56
|
+
First, you'll need to record the page
|
57
|
+
|
58
|
+
since_time = Time.now.to_i # If you don't pass a since time, you'll get all posts in the history of the page
|
59
|
+
page_id = ** your page id **
|
60
|
+
page = Mosaic::Facebook::Graph::Page.new(:id => page_id).feed.all(:access_token => app.access_token, :since => since_time)
|
61
|
+
|
62
|
+
You can then iterate through the posts , grabbing all the fields of each post
|
63
|
+
|
64
|
+
page.feed.all each do |post|
|
65
|
+
from = post.from.all(:fields => 'name,username,picture')
|
66
|
+
puts post.id.to_s
|
67
|
+
puts post.message
|
68
|
+
puts post.created_time
|
69
|
+
puts from.username.blank? ? from.name : from.username
|
70
|
+
puts from.picture # profile photo
|
71
|
+
case post.type
|
72
|
+
when 'link'
|
73
|
+
puts post.link
|
74
|
+
when 'photo'
|
75
|
+
puts post.picture
|
76
|
+
when 'video'
|
77
|
+
puts post.source
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
### Grabbing a list of events from a page
|
82
|
+
|
83
|
+
Take the page we recorded earlier, and much like the post feed, we can now grab the event feed
|
84
|
+
|
85
|
+
events = page.events.all({:access_token => app.access_token})
|
86
|
+
events.each do |event|
|
87
|
+
puts event.name
|
88
|
+
puts event.description
|
89
|
+
puts event.start_time
|
90
|
+
puts event.end_time
|
91
|
+
puts event.location
|
92
|
+
puts event.venue
|
93
|
+
end
|
@@ -2,8 +2,7 @@ module Mosaic
|
|
2
2
|
module Facebook
|
3
3
|
module Graph
|
4
4
|
class Event < Mosaic::Facebook::Graph::GraphObject
|
5
|
-
attr_accessor :id, :name, :description, :start_time, :end_time, :location, :venue, :updated_time, :picture, :ticket_uri
|
6
|
-
|
5
|
+
attr_accessor :id, :name, :description, :start_time, :end_time, :location, :venue, :updated_time, :picture, :ticket_uri, :privacy, :owner, :cover
|
7
6
|
end
|
8
7
|
end
|
9
8
|
end
|
@@ -2,7 +2,7 @@ module Mosaic
|
|
2
2
|
module Facebook
|
3
3
|
module Graph
|
4
4
|
class Post < Mosaic::Facebook::Graph::GraphObject
|
5
|
-
attr_accessor :id, :created_time, :to, :message, :type, :link, :picture, :updated_time
|
5
|
+
attr_accessor :id, :created_time, :to, :message, :type, :link, :picture, :updated_time, :source
|
6
6
|
|
7
7
|
def comments
|
8
8
|
if @comments.is_a?(Hash)
|
metadata
CHANGED
@@ -1,45 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mosaic-facebook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Ajit Singh
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURNakNDQWhxZ0F3SUJB
|
13
|
-
Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREEvTVJBd0RnWURWUVFEREFkcWIy
|
14
|
-
VXUKY0hsdE1SWXdGQVlLQ1pJbWlaUHlMR1FCR1JZR2JXOXpZV2xqTVJNd0VR
|
15
|
-
WUtDWkltaVpQeUxHUUJHUllEWTI5dApNQjRYRFRFek1ETXdOVEU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S
|
31
|
-
dDdVQW85ZGF1WXlEQ2ZSVWcKTDkyK2J0NXZoYzkwRzVPeWREUUFPSCtFWnBH
|
32
|
-
Mkdlc1Fzcy9ya0ZvbTdlY3N6WWV3ZlZXSVhpeVRURWhTeXFyZQp3MGZBN1FZ
|
33
|
-
UmVVSHBlMEpiS1dmRW9CcG5QazRyL2tidHZobXZESklYdnM1TmZ6eVJyU25u
|
34
|
-
S29jRHI1T29RK2lPCldoa2ZabTFyOTgyWTRLWmg4eVI5aVp4QURQSjBVMDJn
|
35
|
-
cWkwT1ZqMjAvRCsvcjJxRkNqV2cwVjAzdTdGNDg2UkwKbkVBa3lXL3NaTjRX
|
36
|
-
Q29RbmpoeDF3MmYrd2FnVURBTzY4L0E1U0kxaUdyZVlRb3VvN1lRS0xNWC9p
|
37
|
-
WlFKYng2QwpzTERtRXdUcgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
38
|
-
date: 2013-06-07 00:00:00.000000000 Z
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
39
13
|
dependencies:
|
40
14
|
- !ruby/object:Gem::Dependency
|
41
15
|
name: faraday
|
42
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
43
18
|
requirements:
|
44
19
|
- - ~>
|
45
20
|
- !ruby/object:Gem::Version
|
@@ -47,6 +22,7 @@ dependencies:
|
|
47
22
|
type: :runtime
|
48
23
|
prerelease: false
|
49
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
50
26
|
requirements:
|
51
27
|
- - ~>
|
52
28
|
- !ruby/object:Gem::Version
|
@@ -54,6 +30,7 @@ dependencies:
|
|
54
30
|
- !ruby/object:Gem::Dependency
|
55
31
|
name: faraday_middleware
|
56
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
57
34
|
requirements:
|
58
35
|
- - ~>
|
59
36
|
- !ruby/object:Gem::Version
|
@@ -61,6 +38,7 @@ dependencies:
|
|
61
38
|
type: :runtime
|
62
39
|
prerelease: false
|
63
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
64
42
|
requirements:
|
65
43
|
- - ~>
|
66
44
|
- !ruby/object:Gem::Version
|
@@ -68,6 +46,7 @@ dependencies:
|
|
68
46
|
- !ruby/object:Gem::Dependency
|
69
47
|
name: multi_xml
|
70
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
71
50
|
requirements:
|
72
51
|
- - ~>
|
73
52
|
- !ruby/object:Gem::Version
|
@@ -75,6 +54,7 @@ dependencies:
|
|
75
54
|
type: :runtime
|
76
55
|
prerelease: false
|
77
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
78
58
|
requirements:
|
79
59
|
- - ~>
|
80
60
|
- !ruby/object:Gem::Version
|
@@ -82,6 +62,7 @@ dependencies:
|
|
82
62
|
- !ruby/object:Gem::Dependency
|
83
63
|
name: activesupport
|
84
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
85
66
|
requirements:
|
86
67
|
- - ~>
|
87
68
|
- !ruby/object:Gem::Version
|
@@ -89,6 +70,7 @@ dependencies:
|
|
89
70
|
type: :runtime
|
90
71
|
prerelease: false
|
91
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
92
74
|
requirements:
|
93
75
|
- - ~>
|
94
76
|
- !ruby/object:Gem::Version
|
@@ -96,6 +78,7 @@ dependencies:
|
|
96
78
|
- !ruby/object:Gem::Dependency
|
97
79
|
name: debugger
|
98
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
99
82
|
requirements:
|
100
83
|
- - ! '>='
|
101
84
|
- !ruby/object:Gem::Version
|
@@ -103,6 +86,7 @@ dependencies:
|
|
103
86
|
type: :development
|
104
87
|
prerelease: false
|
105
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
106
90
|
requirements:
|
107
91
|
- - ! '>='
|
108
92
|
- !ruby/object:Gem::Version
|
@@ -110,6 +94,7 @@ dependencies:
|
|
110
94
|
- !ruby/object:Gem::Dependency
|
111
95
|
name: rspec
|
112
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
113
98
|
requirements:
|
114
99
|
- - ! '>='
|
115
100
|
- !ruby/object:Gem::Version
|
@@ -117,6 +102,7 @@ dependencies:
|
|
117
102
|
type: :development
|
118
103
|
prerelease: false
|
119
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
120
106
|
requirements:
|
121
107
|
- - ! '>='
|
122
108
|
- !ruby/object:Gem::Version
|
@@ -124,6 +110,7 @@ dependencies:
|
|
124
110
|
- !ruby/object:Gem::Dependency
|
125
111
|
name: rake
|
126
112
|
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
127
114
|
requirements:
|
128
115
|
- - ! '>='
|
129
116
|
- !ruby/object:Gem::Version
|
@@ -131,6 +118,7 @@ dependencies:
|
|
131
118
|
type: :development
|
132
119
|
prerelease: false
|
133
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
134
122
|
requirements:
|
135
123
|
- - ! '>='
|
136
124
|
- !ruby/object:Gem::Version
|
@@ -138,6 +126,7 @@ dependencies:
|
|
138
126
|
- !ruby/object:Gem::Dependency
|
139
127
|
name: vcr
|
140
128
|
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
141
130
|
requirements:
|
142
131
|
- - ! '>='
|
143
132
|
- !ruby/object:Gem::Version
|
@@ -145,6 +134,7 @@ dependencies:
|
|
145
134
|
type: :development
|
146
135
|
prerelease: false
|
147
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
148
138
|
requirements:
|
149
139
|
- - ! '>='
|
150
140
|
- !ruby/object:Gem::Version
|
@@ -152,6 +142,7 @@ dependencies:
|
|
152
142
|
- !ruby/object:Gem::Dependency
|
153
143
|
name: webmock
|
154
144
|
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
155
146
|
requirements:
|
156
147
|
- - ! '>='
|
157
148
|
- !ruby/object:Gem::Version
|
@@ -159,6 +150,7 @@ dependencies:
|
|
159
150
|
type: :development
|
160
151
|
prerelease: false
|
161
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
162
154
|
requirements:
|
163
155
|
- - ! '>='
|
164
156
|
- !ruby/object:Gem::Version
|
@@ -173,11 +165,10 @@ extra_rdoc_files: []
|
|
173
165
|
files:
|
174
166
|
- .gitignore
|
175
167
|
- Gemfile
|
168
|
+
- README.md
|
176
169
|
- Rakefile
|
177
170
|
- lib/mosaic-facebook.rb
|
178
|
-
- lib/mosaic/.DS_Store
|
179
171
|
- lib/mosaic/facebook.rb
|
180
|
-
- lib/mosaic/facebook/.DS_Store
|
181
172
|
- lib/mosaic/facebook/api.rb
|
182
173
|
- lib/mosaic/facebook/api/api_object.rb
|
183
174
|
- lib/mosaic/facebook/api/notification.rb
|
@@ -249,26 +240,30 @@ files:
|
|
249
240
|
- spec/vcr/vcr.rb
|
250
241
|
homepage: ''
|
251
242
|
licenses: []
|
252
|
-
metadata: {}
|
253
243
|
post_install_message:
|
254
244
|
rdoc_options: []
|
255
245
|
require_paths:
|
256
246
|
- lib
|
257
247
|
required_ruby_version: !ruby/object:Gem::Requirement
|
248
|
+
none: false
|
258
249
|
requirements:
|
259
250
|
- - ! '>='
|
260
251
|
- !ruby/object:Gem::Version
|
261
252
|
version: '0'
|
253
|
+
segments:
|
254
|
+
- 0
|
255
|
+
hash: -1236313844666775469
|
262
256
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
257
|
+
none: false
|
263
258
|
requirements:
|
264
259
|
- - ! '>='
|
265
260
|
- !ruby/object:Gem::Version
|
266
261
|
version: 1.3.4
|
267
262
|
requirements: []
|
268
263
|
rubyforge_project: mosaic_facebook
|
269
|
-
rubygems_version:
|
264
|
+
rubygems_version: 1.8.23
|
270
265
|
signing_key:
|
271
|
-
specification_version:
|
266
|
+
specification_version: 3
|
272
267
|
summary: gem/plugin to connect to facebook graph api
|
273
268
|
test_files:
|
274
269
|
- spec/api/notification_spec.rb
|
@@ -314,4 +309,3 @@ test_files:
|
|
314
309
|
- spec/vcr/fixtures/cassettes/Mosaic_Facebook_Notification/when_no_or_invalid_token_is_passed/should_require_a_valid_access_token.yml
|
315
310
|
- spec/vcr/fixtures/cassettes/Mosaic_Facebook_Notification/when_no_or_invalid_token_is_passed/should_require_an_access_token.yml
|
316
311
|
- spec/vcr/vcr.rb
|
317
|
-
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
NjUxMjE5MzBiMzJjODMwN2ZhNGVhYzYzNmRiOTkzNjhiNDg0ZDgwNg==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZTE1MjZhZjkwYzE3OGMzYTk1ZTc0ODE0MWJjNGZlYWU1NTFkN2VkMA==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MDNmNjMxMTRkMmU4YjAwZDZmZjM4NTNjZWZlYzhjOGZhMDEwN2YyNzM1NzA0
|
10
|
-
MzQ4NDNkODJiNjcyNTJhMmRlNzMyMDNjNDZiYjAwNTc2MjlkNmZiZGY0NWVk
|
11
|
-
NWIzNDQyZWJhYzAzZjU4MzU4ZGUwOTQ2YTA1MTBlNzA4MjU0ZmE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
Y2E3MWIzNTQ2MGI0OWIwMmU3Njc2MjQyZWRmZGZjZmNkMDU1NzRiM2ZhNjVi
|
14
|
-
MDZhMzViYWMzZDE0ODBkNzFhZDU3MjhlNmM2ODlhMjU1ZmMyMDNjZmM1NTRi
|
15
|
-
YmM4MGIxMTcwYTU1ZWYzYTUyYjZhZDk4M2EwYjQzYWQ3ODcyZDQ=
|