I'm wondering about this: I have a simple facebook-connect app that will only show certain content after you login and liked a certain page. It works (huzzah!) but I want to make it more user friendly by making it refresh automatically after you pressed the like button.
Here's some code:
<?php
if ($me) {
$pageid = -----------;
$uid = $me['id'];
$likeID = $facebook->api(
array( 'method' => 'fql.query', 'query' =>
'SELECT target_id FROM connection WHERE source_id = ' . $uid . ' AND target_id = ' . $pageid )
);
if ( empty($likeID) )
{
// Person is LOGGED IN, but has NOT LIKED
echo '<script src="MY WEBPAGE"></script><fb:like href="MY WEBPAGE" layout="box_count" show_faces="false" width="450"></fb:like>';
}
else
{
// Person is LOGGED IN, and has LIKED, score!
echo 'Download link';
}
}
else
{
// Person is NOT LOGGED IN, so we know NOTHING
echo '<script src="MY WEBPAGE"></script><fb:like href="MY WEBPAGE" layout="box_count" show_faces="false" width="450"></fb:like>';
} ?>
Is there anything I can do to this code (maybe in the fb:like tag?) that makes it reload the page after a like?
Thanks.
As you are using the XFBML implementation, I assume the JS library (http://connect.facebook.net/en_US/all.js#xfbml=1
) is already loaded, so what you need is just this snippet:
<script>
FB.Event.subscribe('edge.create', function(response) {
window.location.reload();
});
</script>