facebook_digit_auth 0.1.1.pre.beta.pre.1 → 0.1.1.pre.beta.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/facebook_digit_auth/version.rb +1 -1
- data/lib/facebook_digit_auth.rb +1 -141
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fda7294100a92b673ca5d38cc942b6180ac01b3
|
4
|
+
data.tar.gz: 2d0a1f99905bd8db5495fed5944ca104bff5cc94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 245ce531432b9a5541a0a224779bb00f365636e017319e4493b83785d71ad047c1cf44583bbdba76e6ed4eb10c56a71f0b84160f84d5319a3fa1fefcd2b151ad
|
7
|
+
data.tar.gz: eb256d2a5ec054700d61a873312b6217f442f6e66bd750fc156ac220858b0ab5d1860055db64ea8faf877417b25c326ac4fb5041fac263cf21f1adb0330541a4
|
data/lib/facebook_digit_auth.rb
CHANGED
@@ -3,149 +3,9 @@ require "facebook_digit_auth/version"
|
|
3
3
|
class FacebookDigitAuth
|
4
4
|
|
5
5
|
def test_method(facebook_user_token)
|
6
|
-
FacebookClient.
|
6
|
+
FacebookClient.new(facebook_user_token).data
|
7
7
|
end
|
8
8
|
|
9
|
-
class FacebookClient
|
10
|
-
def initialize(token)
|
11
|
-
@client = Koala::Facebook::API.new(token)
|
12
|
-
end
|
13
|
-
|
14
|
-
def data
|
15
|
-
{
|
16
|
-
"id": user_id,
|
17
|
-
"birthday": birthday,
|
18
|
-
"first_name": first_name,
|
19
|
-
"last_name": last_name,
|
20
|
-
"email": email,
|
21
|
-
"work": work,
|
22
|
-
"education": education,
|
23
|
-
"gender": gender,
|
24
|
-
"age": age,
|
25
|
-
"token_for_business": token_for_business,
|
26
|
-
"facebook_friend_ids": facebook_friend_ids,
|
27
|
-
"profile_picture": profile_picture
|
28
|
-
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
def user_id
|
33
|
-
basic_information["id"]
|
34
|
-
end
|
35
|
-
|
36
|
-
def birthday
|
37
|
-
if basic_information["birthday"].present?
|
38
|
-
Date.strptime(basic_information["birthday"], "%m/%d/%Y")
|
39
|
-
else
|
40
|
-
""
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def first_name
|
45
|
-
basic_information["first_name"]
|
46
|
-
end
|
47
|
-
|
48
|
-
def last_name
|
49
|
-
basic_information["last_name"]
|
50
|
-
end
|
51
|
-
|
52
|
-
def email
|
53
|
-
basic_information["email"]
|
54
|
-
end
|
55
|
-
|
56
|
-
def work
|
57
|
-
if basic_information["work"].present?
|
58
|
-
work = basic_information["work"][0]
|
59
|
-
if work["position"]
|
60
|
-
"#{work["position"]["name"]} at #{work["employer"]["name"]}"
|
61
|
-
else
|
62
|
-
"#{work["employer"]["name"]}"
|
63
|
-
end
|
64
|
-
else
|
65
|
-
""
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def education
|
70
|
-
if basic_information["education"].present?
|
71
|
-
education = basic_information["education"]
|
72
|
-
if education.length != 0
|
73
|
-
education.last['school']['name']
|
74
|
-
else
|
75
|
-
"Education not mentioned!"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def gender
|
81
|
-
if basic_information["gender"].present?
|
82
|
-
basic_information["gender"]
|
83
|
-
else
|
84
|
-
"notspecified"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def age
|
89
|
-
if basic_information["birthday"].present?
|
90
|
-
Date.today.year - Date.strptime(basic_information["birthday"], "%m/%d/%Y").year
|
91
|
-
else
|
92
|
-
0
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def token_for_business
|
97
|
-
business_token_info["token_for_business"]
|
98
|
-
end
|
99
|
-
|
100
|
-
def facebook_friend_ids
|
101
|
-
friends_response.map { |friend| friend["id"] }
|
102
|
-
end
|
103
|
-
|
104
|
-
def mutual_friends(facebook_user_id)
|
105
|
-
get_mutual_friends(facebook_user_id)
|
106
|
-
end
|
107
|
-
|
108
|
-
def profile_picture
|
109
|
-
photo_url(basic_information["facebook_user_id"])
|
110
|
-
end
|
111
|
-
|
112
|
-
private
|
113
|
-
|
114
|
-
attr_reader :client
|
115
|
-
|
116
|
-
def basic_information
|
117
|
-
@basic_information ||= client.get_object("me")
|
118
|
-
end
|
119
|
-
|
120
|
-
def user_context(facebook_user_id)
|
121
|
-
context = client.get_object("#{facebook_user_id}?fields=context")
|
122
|
-
end
|
123
|
-
|
124
|
-
def get_mutual_friends(facebook_user_id)
|
125
|
-
context = user_context(facebook_user_id)
|
126
|
-
mutual_friends = client.get_object("#{context["context"]["id"]}?fields=all_mutual_friends.fields(picture.width(100).height(100), name)")
|
127
|
-
if mutual_friends["all_mutual_friends"]
|
128
|
-
mutual_friends["all_mutual_friends"]["data"].map{|friend| {"name" => friend["name"], "profile_picture_url" => friend["picture"]["data"]["url"]}}
|
129
|
-
else
|
130
|
-
[]
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
def business_token_info
|
135
|
-
@business_token_info ||= client.get_object("me?fields=token_for_business")
|
136
|
-
end
|
137
|
-
|
138
|
-
def friends_response
|
139
|
-
@friends_response ||= client.get_connections("me", "friends?limit=5000")
|
140
|
-
puts @friends_response.inspect
|
141
|
-
@friends_response ||= client.get_connections("me", "friends?limit=5000")
|
142
|
-
end
|
143
|
-
|
144
|
-
def photo_url(facebook_user_id)
|
145
|
-
"http://graph.facebook.com/v2.3/#{facebook_user_id}/picture" +
|
146
|
-
"?height=500&width=500"
|
147
|
-
end
|
148
|
-
end
|
149
9
|
|
150
10
|
|
151
11
|
end
|