dede中怎麼樣與新浪微博互聯

來源:互聯網
上載者:User

最近在製作dede模板時,發現如果讓新浪微博與dedecms進行關聯,這樣訪問量就能到自己的站上來,讓站上的流量到微博上去,經研究,現在公布方法。

工具/原料
  • dedecms程式,熟悉PHP代碼

步驟/方法
  1. 1

    在DEDECMS的根目錄下建立一個rss.php。內容如下:

    <?php
    require_once (dirname(__FILE__) . "/include/common.inc.php");
    require_once DEDEINC."/arc.partview.class.php";
    $pv = new PartView();
    $pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/default/rss.htm");
    header("Content-type:application/xml");
    $pv->Display();
    ?>

  2. 2

    在dedecms的模板檔案夾下(也就是/templets/default目錄下建立一個rss.htm檔案),其中內容如下:

    <?xml version="1.0" encoding="utf-8" ?>

    <rss version="2.0">

    <channel>

    <title>{dede:global.cfg_webname/}</title>

    <link>{dede:global.cfg_basehost/}</link>

    <description>{dede:global.cfg_description/}</description>

    <language>zh-cn</language>

    <generator>{dede:global.cfg_webname/}</generator>

    <webmaster>{dede:global.cfg_adminemail/}</webmaster>

    {dede:arclist row='100' col='1' titlelen='200' orderby='pubdate'}

    <item>

    <link>[field:arcurl/]</link>

    <title><![CDATA[[field:title function='html2text(@me)'/]]]></title>

    <author>[field:writer/]</author>

    <category>[field:typename/]</category>

    <pubDate>[field:pubdate function='strftime("%a, %d %b %Y %H:%M:%S +0800",@me)'/]</pubDate>

    <guid>[field:arcurl/]</guid>

    <description><![CDATA[[field:description function='html2text(@me)'/] … ]]></description>

    </item>

    {/dede:arclist}

    </channel>

    </rss>

  3. 3

    修改你的首頁模板index.htm在<head>和</head>之間加入一下標記。

    <link rel="alternate" type="application/rss+xml" href="http://www.pekdo.com/rss.php" title="湖北程力專用汽車有限公司" />

  4. 4

    讓新浪微博關聯你的站.

    登陸新浪微博,進入上面帳戶 》我的工具 》 關聯部落格 》 把你的網址貼在框裡 確定就OK了。

    這樣只要你的網站有更新並產生了首頁,新浪微博就會自動更新你更新的最新的微博。

注意事項
  • 在建立這個檔案時,注意檔案編碼,我就是因為編碼問題弄了半天。我使用的是utf-8編碼。

  • 還有就是你首頁更新了有新內容後,並不是立刻就顯示在新浪微博上的,中間是有一個過程的。可能過個幾分鐘或十幾分鐘新浪微博上就有你最新發行的微博了!

  • 注意將文章例子中的網址和名稱更換成你自己的網站。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.