[Plugin: Simple Facebook Connect] Using FB.api with the plugin
-
Hi there,
I’m trying to use the Graph Api with the init made by Simple Facebook Connect. However, it returns an annoying “FB is not defined” message !
This call checks if the user LIKE the page with a specific ID.
$(document).ready(function(){ FB.api('/me/likes/40796308305',function(response) { if( response.data ) { if( !isEmpty(response.data) ) alert('You are a fan!'); else alert('Not a fan!'); } else { alert('ERROR!'); } }); // function to check for an empty object function isEmpty(obj) { for(var prop in obj) { if(obj.hasOwnProperty(prop)) return false; } return true; } });I load my script after the FB.init (which is placed just before the </body> tag). Any clue on how I could solve this ?
function add_facebook_doyoulike() { ?> <script src="<?php echo get_template_directory_uri(); ?>/js/doyoulike.js"></script> <?php } add_action('wp_footer','add_facebook_doyoulike',30);Facebook advice to load the JS SDK just after the <body> tag, could it be the problem here ?
The following code will load and initialize the JavaScript SDK with all common options. Replace YOUR_APP_ID and http://WWW.YOUR_DOMAIN.COM with the appropriate values. The best place to put this code is right after the opening <body> tag.
Thanks in advance.
Jk_
The topic ‘[Plugin: Simple Facebook Connect] Using FB.api with the plugin’ is closed to new replies.