Home >Backend Development >PHP Tutorial >DedeCMS updated articles are simultaneously posted to Sina Weibo, dedecms Sina_PHP tutorial
If you can make good use of Weibo as a tool in the website promotion process, it will bring great benefits to the website promotion work. Come to huge convenience. Let's take the dede program as an example to explain how to automatically synchronize website content to Sina Weibo.
There is a function in the Sina Weibo tool to automatically associate blogs. If you make good use of this function, the newly published content on the website will be automatically synchronized to the Sina blog. As shown below:
Before using this function, you need to create the RSS feed of your website in advance. Let’s take dede as an example to explain how to create the RSS feed of the website.
Create a new feed.php file with the code as shown below. After saving, upload this file to the root directory of your website.
<?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/feed.htm"); header("Content-type:application/xml"); $pv->Display(); ?>
Create a new feed.htm file with the code as shown below. Upload this file to dede's template directory.
<?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='60' col='1' titlelen='100' orderby='pubdate'} <item> <link>http://www.ijinfa.cn[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>http://www.ijinfa.cn[field:arcurl/]</guid> <description><![CDATA[[field:description function='html2text(@me)'/] … ]]></description> </item> {/dede:arclist} </channel> </rss>
Finally, add the following statement between 93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1 in the index.htm template file:
<span class="sh_symbol">3b71b8d1de9b6782e9d4267da5f15fe8 </span>
Regenerate the website homepage in the dede background, so that the RSS feed of your website has been created.