Is there a way to reload the page after clicking <fb: like>?

I'm curious about this: I have a simple facebook-connect application that will show only certain content after logging in and like a certain page. It works (huzzah!), But I want to make it more user-friendly by making it automatically updated after pressing the type button.

Here is the 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 for this code (possibly in the fb: like tag?) That forces it to reload the page after which?

Thank.

+3
source share
1 answer

Since you are using the XFBML implementation, I assume that the JS ( http://connect.facebook.net/en_US/all.js#xfbml=1) library is already loaded, so you only need this snippet:

<script>
FB.Event.subscribe('edge.create', function(response) {
    window.location.reload();
});
</script>
+6
source

Source: https://habr.com/ru/post/1791685/


All Articles