Is the Facebook user ID accessible to an app without authorization? -


i'm writing simple survey app facebook (it form asks books people read). don't want information users (except enter in survey), don't want post wall etc., facebook user id, can recognize duplicates.

if allow users use app without authorization, can still "see" facebook user id?

without authorization?- unfortunately you can't!

the way query current user /me- , requires access token , access token user needs authorize app.

if don't want make sure user don't take survey due this- minute chances there happen since each , every app uses authorization. , you're not requesting basic info. so, think should implement if want unique of user!

but if don't want implement avoid going through docs , all, ill provide small code need user-id-

window.fbasyncinit = function() {    fb.init({      appid      : '{app-id}',       status     : true,       cookie     : true,      xfbml      : true     });     fb.getloginstatus(function(response) {     if (response.status === 'connected') {       var uid = response.authresponse.userid;       // save uid     } else if (response.status === 'not_authorized') {       login();         } else {       login();     }  }); };    (function(d){   var js, id = 'facebook-jssdk', ref = d.getelementsbytagname('script')[0];        if (d.getelementbyid(id)) {return;}   js = d.createelement('script'); js.id = id; js.async = true;   js.src = "https://connect.facebook.net/en_us/all.js";   ref.parentnode.insertbefore(js, ref); }(document));  function login(){  fb.login(function(response) {    if (response.authresponse) {       fb.api('/me', function(response) {           var uid= response.id;           // save uid here       });    } else {      // user did not authorized app, handle accordingly (continue guest /ask auth again refreshing page)    }  }); } 

(just replace {app-id} app-id.)


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -