Last active
September 20, 2017 01:15
-
-
Save bryanrsebastian/011a5c84c13781cf2598ab9bcd408e1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get some data in facebook profile | |
*/ | |
$.ajaxSetup( { cache: true } ); | |
$.getScript( '//connect.facebook.net/en_US/sdk.js', function() { | |
FB.init( { | |
appId: '224429194748109', | |
version: 'v2.7' // or v2.1, v2.2, v2.3, ... | |
} ); | |
$( '#link-fb' ).removeClass('disabled'); | |
$( '#link-fb:not(.disabled)' ).on( 'click', function( e ) { | |
e.preventDefault(); | |
FB.login( function( response ){ | |
if ( response.status === 'connected' ) { | |
FB.api( '/me', { fields: [ 'id', 'email', 'first_name', 'last_name' ] }, function( response ) { | |
$( '.first_name input' ).val( response.first_name ); | |
$( '.last_name input' ).val( response.last_name ); | |
$( '.email_address input' ).val( response.email ); | |
} ); | |
} else { | |
console.log( 'failed login' ); | |
} | |
}, { scope: 'public_profile,email' } ); | |
} ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is good!!!