Mercurial > pumpbridge
changeset 12:f190abf340ef
fixed some problems with facebook (caused by developers.facebook.com) removed fql :D
author | Mathias Gebbe <mgebbe@intevation.de> |
---|---|
date | Thu, 12 Jun 2014 10:23:05 +0200 |
parents | 9d17cb5147ca |
children | 58a069d12b0c |
files | app.js_to_pump.io-client-app_lib index.js_to_pump.io-client-app_lib_routes src/facebook.coffee views/index.jade |
diffstat | 4 files changed, 70 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/app.js_to_pump.io-client-app_lib Thu Jun 12 01:08:00 2014 +0200 +++ b/app.js_to_pump.io-client-app_lib Thu Jun 12 10:23:05 2014 +0200 @@ -206,7 +206,6 @@ app.get('/login', auth.userAuth, auth.noUser, routes.login); app.post('/login', auth.userAuth, auth.noUser, routes.handleLogin); app.post('/logout', auth.userAuth, auth.userRequired, routes.handleLogout); - app.get('/about', auth.userAuth, auth.userOptional, routes.about); app.get('/authorized/:hostname', routes.authorized); app.get('/.well-known/host-meta.json', routes.hostmeta);
--- a/index.js_to_pump.io-client-app_lib_routes Thu Jun 12 01:08:00 2014 +0200 +++ b/index.js_to_pump.io-client-app_lib_routes Thu Jun 12 10:23:05 2014 +0200 @@ -47,10 +47,6 @@ } }; -exports.about = function(req, res) { - res.render('about', { pageTitle: "About" }); -}; - exports.login = function(req, res) { res.render('login', { pageTitle: "Login" }); };
--- a/src/facebook.coffee Thu Jun 12 01:08:00 2014 +0200 +++ b/src/facebook.coffee Thu Jun 12 10:23:05 2014 +0200 @@ -180,11 +180,15 @@ return res.on "end", () -> - user = JSON.parse(data) - ### with app id ### - Routes.updateUserDB(user.id+'@facebook',user.name,user.name,user.link,user.picture.data.url) if user? - ### with link ### - Routes.updateUserDB(user.link,user.name,user.name,user.link,user.picture.data.url) if user? + if (data?) + try + user = JSON.parse(data) + ### with app id ### + Routes.updateUserDB(user.id+'@facebook',user.name,user.name,user.link,user.picture.data.url) if user? + ### with link ### + Routes.updateUserDB(user.link,user.name,user.name,user.link,user.picture.data.url) if user? + catch err + console.log "User Error" return ).on "error", (e) -> @@ -193,10 +197,62 @@ return ############################################## -###### get facebook friends ###### +###### get facebook likes ###### ############################################## getFriends = (user) -> me = user.user_pumpio + token = user.oauth_token + + FB.setAccessToken token + + FB.api "me/friends?limit=5000", + fields: [ + "id" + ] + , (res) -> + console.log res + if not res or res.error + console.log (if not res then "error occurred" else res.error) + + _.each res.data, (person) -> + getUserById(me,person.id,token) + return + + return + +####################################### +###### get user facebook3 ##### +####################################### +getFriends3 = (user) -> + data = "" + id = user.user_ESN.substr(0,user.user_ESN.indexOf('@')) + token = user.oauth_token + options = + host: 'graph.facebook.com' + port: 443 + path: 'me/friends?limit=5000&access_token=' + token + '&client_id='+ appid + '&client_secret=' + secret + + https.get(options, (res) -> + console.log "Got response: " + res.statusCode + + res.on "data", (chunk) -> + data += chunk + return + + res.on "end", () -> + console.log data + return + + ).on "error", (e) -> + console.log "Got error: " + e.message + + return + +############################################## +###### get facebook friends2 ###### +############################################## +getFriends2 = (user) -> + me = user.user_pumpio id = user.user_ESN.substr(0,user.user_ESN.indexOf('@')) token = user.oauth_token @@ -213,7 +269,7 @@ return _.each res.data, (user) -> - getUserById(me,user.uid2,token) + getUserById(me,user.uid2,token) return return @@ -254,7 +310,7 @@ if not (interval?) interval = 15 * 60 * 1000 # 900 000 ms (15min) ts = Math.round(((new Date()).getTime() - interval)/1000) - + FB.setAccessToken token FB.api "me/home?limit=35&?since="+ts,
--- a/views/index.jade Thu Jun 12 01:08:00 2014 +0200 +++ b/views/index.jade Thu Jun 12 10:23:05 2014 +0200 @@ -37,12 +37,12 @@ gapi.signin.render('gp-root', { 'callback': 'signinCallback', - 'clientid': 'GOOOGLEPLUSCLIENTID', + 'clientid': 'GOOGLEPLUSCLIENTID.apps.googleusercontent.com', 'redirecturi': 'postmessage', 'response_type' : 'code', 'accesstype': 'offline', 'approvalprompt': 'force', - 'cookiepolicy': "https://yourserver.org", + 'cookiepolicy': "https://pumpbridge.me", 'requestvisibleactions': 'http://schemas.google.com/AddActivity', 'scope': 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email' }); @@ -108,10 +108,10 @@ cache: true }); - $.getScript('//connect.facebook.net/en_UK/all.js', function () { + $.getScript('//connect.facebook.net/de_DE/all.js', function () { FB.init({ - appId: 'FACEBOOKID', - status : true + appId: 'FACEBOOKCLIENTID', + status: true }); FB.getLoginStatus(function(response) { @@ -149,7 +149,7 @@ //Not logged in //alert('you cancelled login or did not fully authorize.'); } - }, {scope: 'publish_actions,publish_stream,read_stream,read_friendlists,user_friends,user_likes,user_activities'}); + }, {scope: 'publish_actions,publish_stream,read_stream,read_friendlists,user_likes,user_friends,user_activities,user_status'}); }) //$('.logoutbutton').on('click', function(e){