Skip to content

Instantly share code, notes, and snippets.

@bryanrsebastian
Last active September 20, 2017 01:15
Show Gist options
  • Save bryanrsebastian/011a5c84c13781cf2598ab9bcd408e1a to your computer and use it in GitHub Desktop.
Save bryanrsebastian/011a5c84c13781cf2598ab9bcd408e1a to your computer and use it in GitHub Desktop.
/**
* 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' } );
} );
} );
@rjconcepcion
Copy link

this is good!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment