Facebook connect - Javascript -
i'm trying implement facebook connect on website filling input fields.
but can't email address or last , first name despite facebook application ask me if can access email address.
here script:
<script> window.fbasyncinit = function() { fb.init({ appid : '######', // app id status : true, // check login status xfbml : true, cookie : true, version : 'v2.4' // version }); }; function login() { fb.login(function(response) { if(response.authresponse) { getuserinfo(); }else{ console.log('user cancelled login or did not authorize.'); } },{scope: 'public_profile,email'}); } function getuserinfo() { fb.api('/me', function(response) { document.getelementbyid("name").value = response.name; document.getelementbyid("first_name").value = response.first_name; document.getelementbyid("last_name").value = response.last_name; document.getelementbyid("email").value = response.email; fb.api('/me/picture?type=normal', function(response) { var str ="<br/><b>pic</b> : <img src='"+response.data.url+"'/>"; str +="<input type='button' value='logout' onclick='logout();'/>"; document.getelementbyid("status").innerhtml=str; }); }); } function logout() { fb.logout(function(){document.location.reload();}); } // load sdk asynchronously (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 = "//connect.facebook.net/en_en/all.js"; ref.parentnode.insertbefore(js, ref); }(document)); </script>
can me this?
you should explicitly requests fields need:
fb.api('/me?fields=email,...')
see chapter choosing fields
in using graph api doc
you can try requests using graph api explorer
in tool & support section in fb developer site
Comments
Post a Comment