Mam skrypt umożliwiający sprawdzenie, czy osoba kliknęła lubię to na facebooku na danej stronie, jeśli tak, pokazuje isętreść X, jeśli nie to może na przykłąd wyskoczyć info aby polubił.

Lecz strypt jest ten dowklejenia w iframe tab na facebooku, ja chciałbym go umieścić na mojej stronie internetowej.

Źródło skryptu: http://www.pedalo.co.uk/blog/index.php/how...page-with-php/#

Skrypt:

  1. $session = $facebook->getSession();
  2.  
  3. /*If you get a session here it means that a correctly signed session exists (using the Application Secret that only Facebook and the Application know). Note that even though a session is found it doesn’t mean it is still valid. The session could have expired or the user might have logged out. This is handled with the exception model try and catch. If the session isn’t valid anymore the exception will be caught.
  4.  
  5. Continue like this.*/
  6. if ($session) {
  7. $user = $facebook->getUser(); //get the user id
  8.  
  9. $page = ' XXXXXXXXXXX'; //replace XXXXXXXXXXX with the page id
  10.  
  11. try {
  12.  
  13. $likeID = $facebook->api(array( 'method' => 'fql.query', 'query' => 'SELECT target_id FROM connection WHERE source_id =' . $user . 'AND target_id =' .$page ));
  14.  
  15. /* Using a fql.query like this checks the current user (source_id) likes (connection) a page (target_id).
  16.  
  17. Without the AND target_id =' .$page at the end of our query, it would return all the pages and friends the user likes, is a fan of or is a friend with. Since we included the AND we will now only get a return value if the user likes our specific page.
  18.  
  19. If $likeID is empty the user doesn’t like our page and if $likeID is not empty the user likes it.
  20.  
  21. You can now show the user different content with a simple if statetment like below.*/
  22.  
  23. if ( empty($likeID) ) {
  24.  
  25. // user HAS NOT Liked the page
  26.  
  27. echo "<h2>Like my page!</h2>";
  28.  
  29. }
  30.  
  31. else {
  32.  
  33. // user HAS Liked the page
  34.  
  35. echo "<h2>Thank you for liking my page</h2>";
  36.  
  37. }
  38.  
  39. }
  40.  
  41. // if the session has expired, ask the user to login in to Facebook
  42.  
  43. catch (FacebookApiException $e) {
  44.  
  45. echo 'Please login to Facebook';
  46.  
  47.  
  48. }
  49.  
  50. }
  51.  
  52. ?>
  53.  
  54. That&#8217;s it. You now have a Facebook page tab that shows different content whether the user liked the page or not. You probably want to show something more than just “Like my page!” and “Thank you for liking my page”. You can for example replace the two echoes of h2 tags with an include("notlike.php"); and include("like.php"); like this :
  55.  
  56. if ( empty($likeID) ) {
  57.  
  58. // user HAS NOT Liked the page
  59.  
  60. include("notlike.php")
  61.  
  62. }
  63.  
  64. else {
  65.  
  66. // user HAS Liked the page
  67.  
  68. include("like.php");
  69.  
  70. }


Proszę o pomoc.