check the user like of the like button and display something immediately in facebook app, 謝謝

edited 四月 2014 in 進階PHP討論
I have a question which I have tested many times.
How I can check the user like of the like button and display something immediately?

<? ob_start(); ?>
header(\"Content-Type:text/html; charset=utf-8\");
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"\">
<html xmlns=\"\">
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<meta http-equiv=\"content-language\" content=\"zh-hk\">
<title>My Travel Package</title>
<div id=\"fb-root\"></div>
window.fbAsyncInit = function() {
appId : '611082462236661',
status : true,
xfbml : true
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); = id;
js.src = \"//\";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
require 'src/facebook.php';
$app_id = \"611082462236661\";
$app_secret = \"ae07bc7c7da48c5f432fce167297e918\";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
$signed_request = $facebook->getSignedRequest();
$liked = $signed_request[page][liked];
if ($liked==1) {
echo'<img src=\"fb.jpg\"/>';
echo'<div class=\"fb-share-button\" data-href=\"\" data-type=\"button_count\"></div>';
} else {
echo'Please like us!';
echo'<div class=\"fb-like\" data-href=\"\" data-layout=\"button_count\" data-action=\"like\" data-show-faces=\"false\" data-share=\"false\"></div>';

Hope you can help me. Thanks.


Sign In or Register to comment.