DEDECMS站点内容怎么自动更新到新浪微博

来源:undefined 2024-12-29 11:24:01 1043

dedecms站点内容怎么自动更新到新浪微博?

DEDECMS站点内容自动更新到新浪微博

推荐学习:织梦cms

新浪微博是利用feed找到更新文章的。只要给他指定feed地址就可以成功关联啦。

现在开始动手简单修改一下织梦的模板,由于织梦不能生成全站的xml文件,所以要先建立生成全站XML的php程序。

1,建立feed.php

1

2

3

4

5

6

7

8

<?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 . "/feed.htm");   

header("Content-type:application/xml");   

$pv-&gt;Display();   

?&gt;

登录后复制

以上要注意的是修改模板的路径,确保在模板跟目录能够找到feed.htm

2,建立feed.htm模板文件

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

<?xml  version="1.0" encoding="gb2312" ?>   

<rss>   

<channel>   

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

<link>{dede:global.cfg_basehost/}   

<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>[field:arcurl/]   

<title></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></description>   

</item>   

{/dede:arclist}   

</channel>   

</rss>

登录后复制

需要注意的是,别忘了把我的网址改成你自己需要的。

3,修改index.htm主页模板

由于新浪微博只能验证网址,不能写完整路径,比如我写的是:。结果提示关联失败,解决的办法是,在

和中间加入下面的代码

1

<link>

登录后复制

以上就是DEDECMS站点内容怎么自动更新到新浪微博的详细内容,更多请关注php中文网其它相关文章!

最新文章