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

edited 四月 2014 in 進階PHP討論
HI EVERYONE,
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?
https://www.facebook.com/keung725/app_611082462236661
http://mycoupon.com.hk/1/

<? ob_start(); ?>
<?php
header("Content-Type:text/html; charset=utf-8");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">;
<html xmlns="http://www.w3.org/1999/xhtml">;
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="content-language" content="zh-hk">
<title>My Travel Package</title>
</head>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
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); js.id = id;
js.src = "//connect.facebook.net/zh_HK/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<body>
<?php
mb_internal_encoding('UTF-8');
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="https://www.facebook.com/keung725"; data-type="button_count"></div>';
} else {
echo'Please like us!';
echo'<div class="fb-like" data-href="https://www.facebook.com/keung725"; data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>';
}
?>
</body>
</html>


Hope you can help me. Thanks.
標籤:

評論

Sign In or Register to comment.