Mercurial > pumpbridge
comparison src/facebook.coffee @ 11:9d17cb5147ca
back to fql, added fb user_friends permission
author | Mathias Gebbe <mgebbe@intevation.de> |
---|---|
date | Thu, 12 Jun 2014 01:08:00 +0200 |
parents | ccf1d9e741bd |
children | f190abf340ef |
comparison
equal
deleted
inserted
replaced
10:ccf1d9e741bd | 11:9d17cb5147ca |
---|---|
195 ############################################## | 195 ############################################## |
196 ###### get facebook friends ###### | 196 ###### get facebook friends ###### |
197 ############################################## | 197 ############################################## |
198 getFriends = (user) -> | 198 getFriends = (user) -> |
199 me = user.user_pumpio | 199 me = user.user_pumpio |
200 id = user.user_ESN.substr(0,user.user_ESN.indexOf('@')) | |
200 token = user.oauth_token | 201 token = user.oauth_token |
201 | 202 |
202 EdgeControl.removeEdges(me,'@facebook') | 203 EdgeControl.removeEdges(me,'@facebook') |
203 EdgeControl.removeEdges(me,'www.facebook.com') | 204 EdgeControl.removeEdges(me,'www.facebook.com') |
204 | 205 |
205 FB.setAccessToken token | 206 FB.setAccessToken token |
206 | 207 FB.api "fql", |
207 FB.api "me/friends?limit=500", | 208 q: "SELECT uid2 FROM friend WHERE uid1 = me()" |
208 fields: [ | |
209 "id" | |
210 ] | |
211 , (res) -> | 209 , (res) -> |
210 console.log res | |
212 if not res or res.error | 211 if not res or res.error |
213 console.log (if not res then "error occurred" else res.error) | 212 console.log (if not res then "error occurred" else res.error) |
214 | 213 return |
215 _.each res.data, (page) -> | 214 |
216 getUserById(me,page.id,token) if user.id? | 215 _.each res.data, (user) -> |
217 return | 216 getUserById(me,user.uid2,token) |
217 return | |
218 | |
219 return | |
218 | 220 |
219 return | 221 return |
220 | 222 |
221 | 223 |
222 ############################################## | 224 ############################################## |
235 , (res) -> | 237 , (res) -> |
236 if not res or res.error | 238 if not res or res.error |
237 console.log (if not res then "error occurred" else res.error) | 239 console.log (if not res then "error occurred" else res.error) |
238 | 240 |
239 _.each res.data, (page) -> | 241 _.each res.data, (page) -> |
240 getUserById(me,page.id,token) if user.id? | 242 getUserById(me,page.id,token) |
241 return | 243 return |
242 | 244 |
243 return | 245 return |
244 | 246 |
245 | 247 |