Search code examples
phphtmlfacebook-like

Facebook like button with custom link


I am building a facebook like button , in the href tag i want to keep my own custom url stored in php variable. But the like button doesn't shows with it. Any solution

CODE

<?php echo '<fb:like href=" '.$urlToLink.' " width="450" layout="box_count" show_faces="false" send="false"></fb:like>'; ?>

$urlToLink has somethig like this-> "http://localhost/website/view.php?asdpfimi34mmksd"


Solution

  • Put the URL in the debugger and check it for Errors/Warnings: https://developers.facebook.com/tools/debug

    Also, try the URL in the Plugin generator: https://developers.facebook.com/docs/reference/plugins/like/ - and see if it gets rendered correctly.

    And i hope you´re not serious with "localhost", because that will not work, of course. Facebook does not have access to your localhost, and the URL you provide has to be accessible in public, without any user login.