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?