我也是現在才知道~原來在粉絲團按讚就等於加入粉絲團了!!
粉絲團內容+按讚使用like_box,
如果要跟網路上一樣精簡只有讚按紐可以用like_button
官網上這些被列入plugin, 還有預覽跟gen code很貼心!!
http://developers.facebook.com/docs/reference/plugins/like-box/
在送出page前check有沒有加入粉絲團一樣用FB.api...
此頁是接在之前登入APP後做的~ 所以能來到這的user是都已經登入過囉!!
---html/jsp include
<script src="http://connect.facebook.net/zh_TW/all.js"></script>
<div id="like_box" style="margin-top:5px;display:none">
<div class="fb-like-box" data-href="http://www.facebook.com/tyepb" data-width="300" data-show-faces="true" data-stream="false" data-header="false"></div>
</div>
---script/js file
FB.init({
appId: '{APP_ID}', // App ID
//channelURL: '....................', // Channel File
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
oauth: false, // enable OAuth 2.0
xfbml: true // parse XFBML
});
function fan2() {
var pid = '{PAGE_ID}';
var isFan = false;
FB.api('/me/likes/'+pid,function(response) {
//console.log(response);
if( response.data ) {
if(response.data) {
for(var i = 0 ; i < response.data.length ; i++) {
if(pid == response.data[i].id) {
isFan = true;
//console.log('??it is fan!!');
//return true;
}
}
}
if(isFan) {
//do something when user like fans page
} else {
//do something when user unlike fans page
return false;
}
} else {
//user not login/or not connect FB APP
return false;
}
});
return false;
}
沒有留言:
張貼留言