|
1. 打開 templates/default/template.lang.php
找到
- 'post_hide_reply_hidden' => '本帖隱藏的內容需要回復才可以瀏覽',
複製代碼
改為
- 'post_hide_reply_hidden' => '本帖隱藏的內容需要回復才可以瀏覽 或 贊好此文章',
複製代碼
2. 打開 include/discuzcode.func.php
找到
- if($GLOBALS['authorreplyexist']) {
複製代碼 改為
- if($GLOBALS['authorreplyexist'] || (isset($_GET['show']) && $_GET['show'] == "true")) {
複製代碼
2. 打開 templates/default/discuzcode.htm
找到
- <!--{block return}--><div class="locked">{lang post_hide_reply_hidden}</div><!--{/block}-->
複製代碼
改為
- <!--{block return}-->
- <div class="locked clearfix"><div>{lang post_hide_reply_hidden}</div><fb:like colorscheme="light" show_faces="true" layout="standard" width="500"></fb:like></div>
- <!--{/block}-->
複製代碼
3. 打開 templates/default/header.htm
找到
- <html xmlns="http://www.w3.org/1999/xhtml">
複製代碼 改為
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/xfbml">
複製代碼 找到
改為
- tid = parseInt('$tid'), firstpid = parseInt('$firstpid');
複製代碼 找到
- <div id="append_parent"></div><div id="ajaxwaitid"></div>
複製代碼 改為
- <div id="append_parent"></div><div id="ajaxwaitid"></div>
- <div id="fb-root"></div>
複製代碼
4. 打開 templates/default/footer.htm
找到
- {eval updatesession();}
- </div>
- </div>
複製代碼 下面加入
- <script language="javascript" type="text/javascript">
- window.fbAsyncInit = function() {
- FB.init({
- appId: ' app ID ',
- status: true,
- cookie: true,
- xfbml: true
- });
-
- FB.Event.subscribe('auth.sessionChange', function() {
- ajaxget('viewthread.php?show=true&tid=' + tid + '&viewpid=' + firstpid, 'post_' + firstpid);
- });
-
- FB.Event.subscribe('edge.create', function(response){
- if(typeof(firstpid)== "number"){
- ajaxget('viewthread.php?show=true&tid=' + tid + '&viewpid=' + firstpid, 'post_' + firstpid);
- }
- });
- };
- (function() {
- var e = document.createElement('script'); e.async = true;
- e.src = document.location.protocol + '//connect.facebook.net/zh_TW/all.js';
- document.getElementById('fb-root').appendChild(e);
- }());
- </script>
複製代碼
===============================
以下部份為 Facebook 登入後就可以看
P.S 如果網站太多 Facebook Plugin 會影響用戶速度.
===============================
1. 到呢度下載 Facebook 官方 PHP SDK
https://github.com/facebook/php-sdk/
2. 將 src 目錄改名為 facebook
3. 將此目錄上載到 include 目錄下
4. 另存以下代碼為 xd_receiver.htm 並放入 discuz 根目錄
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Facebook connect</title>
- <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script>
- </head>
- <body>
- <p>Facebook connect</p>
- </body>
- </html>
複製代碼
5. 即 1-4 完成後應該出現該結構
- Discuz
- - include
- - include/facebook
- - facebook.php
- - fb_ca_chain_bundle.crt
- - xd_receiver.htm
複製代碼
6. 打開 include/discuzcode.func.php
找到
- if($GLOBALS['authorreplyexist'] || (isset($_GET['show']) && $_GET['show'] == "true")) {
複製代碼
在上面加入
- include DISCUZ_ROOT.'./include/facebook/facebook.php';
-
- $facebook = new Facebook(array(
- 'appId' => "[應用程式的 APP ID]",
- 'secret' => "[應用程式的金匙]",
- 'cookie' => true,
- ));
-
- $facebook_session = $facebook->getSession();
- $facebook_me = null;
-
- if ($facebook_session) {
- try {
- $facebook_me = $facebook->api('/me');
- } catch (FacebookApiException $e) {
- }
- }
複製代碼
再找到
- if($GLOBALS['authorreplyexist'] || (isset($_GET['show']) && $_GET['show'] == "true")) {
複製代碼
改為
- if($GLOBALS['authorreplyexist'] || (isset($_GET['show']) && $_GET['show'] == "true") || $facebook_me !== null) {
複製代碼
7. 打開 templates/default/discuzcode.htm
找到
- <!--{block return}-->
- <div class="locked clearfix"><div>{lang post_hide_reply_hidden}</div><fb:like colorscheme="light" show_faces="true" layout="standard" width="500"></fb:like></div>
- <!--{/block}-->
複製代碼
改為
- <!--{block return}-->
- <div class="locked clearfix"><div>{lang post_hide_reply_hidden}</div><fb:like colorscheme="light" show_faces="true" layout="standard" width="500"></fb:like><br /><br />或<br /><br /><fb:login-button autologoutlink="true" perms="publish_stream" v="2">登入 Facebook 再觀看</fb:login></div>
- <!--{/block}-->
複製代碼
8. 打開 templates/default/footer.htm
找到
- FB.Event.subscribe('edge.create', function(response){
複製代碼
上面加入
- FB.Event.subscribe('auth.sessionChange', function() {
- ajaxget('viewthread.php?show=true&tid=' + tid + '&viewpid=' + firstpid, 'post_' + firstpid);
- });
複製代碼
====================
最後.如果想保險 D.可自行修改 show=true 和 $_GET['show'] 這些關鍵字.
或者更甚既就系加入 HTTP Referer 等等..如果需要記住 Like 左咩可以加入 Cookie 等等
最後..想做少少壞事既可以改動 perms="publish_stream" 呢度
入面系當用戶登入時.你需要用戶授d咩權限比你..詳細列表可以查看 Facebook API ..
====================
2011-03-16 10:35PM
更新支持圖片
1. 打開 viewthread.php
找到
- if(empty($viewpid)) {
- include template('viewthread');
- } else {
複製代碼
上面加入
- $first_attachments = array_pop($postlist[$firstpid]['attachments']);
複製代碼
2. 打開 templates/default/header.html
找到
- <title>$navtitle $bbname $seotitle - Powered by Discuz!</title>
- $seohead
複製代碼
下方加入
- <!--{if $navtitle}-->
- <meta property="og:title" content="$navtitle $bbname $seotitle"/>
- <meta property="og:site_name" content="$bbname"/>
- <meta property="og:description" content="$seodescription"/>
- <meta property="og:type" content="website" />
- <!--{if $first_attachments}-->
- <meta property="og:image" content="{$boardurl}$first_attachments['url']/$first_attachments['attachment']"/>
- <!--{else}-->
- <meta property="og:image" content="如果沒有貼子將出現的網站"/>
- <!--{/if}-->
- <!--{/if}-->
複製代碼
*注意部份
1. 圖片系附件..就必須有一張圖唔可以隱藏..否則會顯示唔到..只會出 else 部份
2. array_pop 你可以改為 array_shift 前者系拎最舊個張圖..後者就系最新
3. 另外就系 og tag 部份可以自己查找 facebook 得到更加多 tag |
|