0

This is not a dup of How to check if a user likes my Facebook Page or URL using Facebook's API which is about Liking Fan pages on Facebook With and appId... This is about Liking a url without a appId.

I see 3 tests to see if someone has Liked (or fan) my Facebook APP, but how do I test if someone has Liked my url (not necessarily right now, maybe a week ago)? To be tested from my url in php. The Like button greys I think if it has already been done, maybe that is a way, but that would be js, not php. I'll take js if it is the only way.

<p data-href="http://www.brain-games-for-fun.com" data-send="false"
 data-layout="button_count" 
data-width="50" data-show-faces="false" data-colorscheme="dark"></p>

(core facebook js function() clipped) 

<?php

require 'face_sdk/face/src/facebook.php';

$facebook = new Facebook(array(
  'appId' => 'www.brain-games-for-fun.com',
  'secret' => '',
));

$user = $facebook->getUser();
$page = 'www.brain-games-for-fun.com';

if ($user) {
   try { 
  $likeID = $facebook->api(array( 'method' => 'fql.query', 'query' =>
      'SELECT target_id FROM connection WHERE source_id =' . $user . 
              'AND target_id =' .$page ));
  if ( empty($likeID) ) {
      // user has NOT Liked the page
      echo "Like my page!";
  } else {
      // user HAS Liked the page
      echo "Thank you for liking my page";
  }
  } catch (FacebookApiException $e) { error_log($e); }
} else {
    echo 'click to sign in so I can see if you Liked me in the past<br/>';
}

Above does not work. I don't have a APP_ID, APP_SECRET, etc for a url! So even if I log in Facebook via hitting the Like button, above never runs the if ($user) block. (it does grey the button though). Am I supposed to make a Facebook web app (out of sandbox) just so someone can Like my url?

Community
  • 1
  • 1
dako
  • 41
  • 5
  • I think the deal is if I want to do this, I have to register a developer account in developers.facebook.com, verifty phone number, and get a appId / secret, even though I don't have an app. That is a bit ugly. There is no other way? – dako Feb 26 '13 at 01:53
  • I see an ugly js method... the Like is actually an iframe, with 2 main divs, one getting class hidden_elem if this user liked or not. No ids, so would have to step thru every document div... ugly. sb a php way. – dako Feb 26 '13 at 06:29
  • http://stackoverflow.com/questions/5574443/do-i-need-an-appid-for-a-xfbml-version-of-the-facebook-like-button – dako Feb 26 '13 at 19:29

0 Answers0