我想知道是否可以使用FB JS SDK在我的Facebook应用程序( iframe )中获取like status
。
我想要的是以下但是在JS中。
<?php require 'lib/facebook.php';
$facebook = new Facebook( array(
'appId' => APP_ID,
'secret' => APP_SECRET,
'cookie' => true
) );
try {
$me = $facebook->api('/me');
} catch ( FacebookApiException $e ) {
error_log( $e );
}
$signed_request = $facebook->getSignedRequest();
$liked = $signed_request['page']['liked'];
?>
<?php
if ( $liked ) : ?>
YOU LIKE US!
<?php else : ?>
YOU DON'T LIKE US YET!
<?php endif; ?>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
答案 0 :(得分:3)
var session = FB.getSession();
FB.api(
{
method: 'fql.query',
query: 'SELECT uid, page_id FROM page_fan WHERE uid=' + session.uid + ' AND page_id=YOUR_APP_ID'
},
function(response) {
if(response instanceof Array && response.length > 0)
alert("YOU LIKE US!");
else
alert("YOU DON'T LIKE US YET!");
}
);