Reputation: 43
how to put this into a <script> or javascript setup
https://api.facebook.com/method/fql.query?format=json&query=select+fan_count+from+page+where+page_id%3D80177638103
that will return the fan_count nos. to a page.
<p> fan_count </p>
Upvotes: 1
Views: 1205
Reputation: 146191
If you you just want to use plain javascript then you can use
<script>
function showCount(count){
if(count)
document.getElementById('fb_fan_count').innerHTML = 'Total fans : ' + count[0].fan_count;
}
</script>
<p id="fb_fan_count"></p>
<script type="text/javascript" src="https://api.facebook.com/method/fql.query?format=json&callback=showCount&query=select+fan_count+from+page+where+page_id%3D80177638103"></script>
DEMO.
Upvotes: 1
Reputation: 2417
Haven't tested this but something like this should do the trick. You might just have to replace the results.fan_count
with the correct object name that Facebook outputs.
$.getJSON('https://api.facebook.com/method/fql.query?format=json&query=select+fan_count+from+page+where+page_id%3D80177638103', function( results ) {
$('body').html(
$.map( results.fan_count, function( obj, index ) {
return '<p>' + obj.text + '</p>'
}).join('')
);
});
Upvotes: 0