I am retrieving a Facebook Page Like count via a PHP function like this:
<?php
function fbLikeCount($id,$appid,$appsecret){
$json_url ='https://graph.facebook.com/'.$id.'?access_token='.$appid.'|'.$appsecret.'&fields=likes';
$json = file_get_contents($json_url);
$json_output = json_decode($json);
if($json_output->likes){
return $likes = $json_output->likes;
}else{
return 0;
}
}
?>
Then, I am able to echo this out no problem like this:
<?php
echo number_format(fbLikeCount('companynamegoeshere','XXXXXXXXXXXX','XXXXXXXXXXX'));
?>
But, I am using a JavaScript function to do this animation for where teh number is displayed on the page, like this:
<script>
$({someValue: 0}).animate({someValue: 450700}, {
duration: 3000,
easing: 'swing',
step: function () {
$('#facebookCount').text(commaSeparateNumber(Math.round(this.someValue)));
},
complete:function(){
$('#facebookCount').text(commaSeparateNumber(Math.round(this.someValue)));
}
});
</script>
Where that 450700 is in the JS code is where I need to put the PHP echo'ed number. Is it even possible to put a PHP echo (if I make it a variable first?) into the JS.
I've tried many, many things and hitting a brick wall. Any help is greatly appreciated.
thanks!