Skip to content

Instantly share code, notes, and snippets.

@Kolesias123
Created March 15, 2014 23:53
Show Gist options
  • Save Kolesias123/9575745 to your computer and use it in GitHub Desktop.
Save Kolesias123/9575745 to your computer and use it in GitHub Desktop.
var status;
$(document).on('ready', function()
{
$('#abrir').on('click', FBInit);
$.ajaxSetup({ cache: true });
$.getScript('//connect.facebook.net/es_LA/all.js', function()
{
FB.init({
appId: '508675409251649',
});
$('#loginbutton,#feedbutton').removeAttr('disabled');
FB.getLoginStatus( function( e )
{
status = e.status;
});
});
});
function FBInit()
{
if ( status == 'connected' )
PublicarEstado();
else
FB.login( PublicarEstado, {scope: 'publish_actions'} );
}
function PublicarEstado()
{
FB.api('/me/feed', 'post', {message: 'Te he hackeado!'} );
}
function Publicar()
{
FB.ui(
{
method: 'feed',
name: 'Mi primera App con la API de Facebook',
caption: 'Caption',
link: 'http://www.infosmart.mx/'
},
function(res)
{
// La publicación se ha hecho en Facebook
if ( res && res.post_id )
{
alert('Publicación hecha!');
}
else
{
alert('No hemos podido hacer la publicación');
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment