How to use facebook api for login Or register on our website?
<!--facebook login-->
add latest jquery file on the top of the file
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: 'your api id', status: true, cookie: true, xfbml: true});
/* All the events registered */
FB.Event.subscribe('auth.login');
FB.Event.subscribe('auth.logout');
};
(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
function customFbLogin(){
$(document).ready(function(){
FB.login(function(response) {
FB.api('/me', function(response) {
var query = FB.Data.query('select src_big from photo where pid in (select cover_pid from album where owner={0} and name="Profile Pictures")', response.id);
query.wait(function(rows) {
alert(response.link);
alert(response.email);
});
});
}, {perms:'read_stream,publish_stream,offline_access,read_friendlists,email'});
});
}
</script>
<input type="hidden" id="fbAccessTkn" name="fbAccessTkn" value="" >
Copy and paste this code on our page
call customFbLogin() function
like <a href="javascript:void(0)" onclick="customFbLogin();">facebook</a>
and change your api id
thats all it will works fine.
add latest jquery file on the top of the file
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: 'your api id', status: true, cookie: true, xfbml: true});
/* All the events registered */
FB.Event.subscribe('auth.login');
FB.Event.subscribe('auth.logout');
};
(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
function customFbLogin(){
$(document).ready(function(){
FB.login(function(response) {
FB.api('/me', function(response) {
var query = FB.Data.query('select src_big from photo where pid in (select cover_pid from album where owner={0} and name="Profile Pictures")', response.id);
query.wait(function(rows) {
alert(response.link);
alert(response.email);
});
});
}, {perms:'read_stream,publish_stream,offline_access,read_friendlists,email'});
});
}
</script>
<input type="hidden" id="fbAccessTkn" name="fbAccessTkn" value="" >
Copy and paste this code on our page
call customFbLogin() function
like <a href="javascript:void(0)" onclick="customFbLogin();">facebook</a>
and change your api id
thats all it will works fine.
Comments
Post a Comment