asp老师 发表于 2015-1-11 13:00:00

QQ互联发帖同步和分享到腾讯微博默认文字的代码分析

本帖最后由 asp老师 于 2015-1-11 13:03 编辑

QQ微博推送的格式固定,如果你不喜欢discuz默认的格式和调用的内容应该如何修改呢?下面简单的分享QQ互联插件的微博分析的一些代码,让你可以自助打造个性化的分享内容。




一、发帖同步到微博时格式:

发帖时的默认文字所在的代码分析
找到文件source/plugin/qqconnect/connect_feed.php 第77行
$_t_content = lang('plugin/qqconnect', 'connect_feed_iam');
$_t_content .= '#' . cutstr($_G['setting']['bbname'], 20,'') . '#';
$_t_content .= lang('plugin/qqconnect', 'connect_feed_published_thread', array('subject' => cutstr($thread['subject'], 120)));
$_t_content .= cutstr(strip_tags($html_content), 80);
$_t_content .= ' ' . $url;详解如下:
$_t_content = lang('plugin/qqconnect', 'connect_feed_iam');
//'connect_feed_iam' ='我在';修改要到\source\plugin\qqconnect\discuz_plugin_qqconnect.xml134行修改;
$_t_content .= '#' . cutstr($_G['setting']['bbname'], 20,'') . '#';
//#网站名字#;修改要到 后台——》全局——》站点名称修改;
$_t_content .= lang('plugin/qqconnect', 'connect_feed_published_thread', array('subject' => cutstr($thread['subject'], 120)));
//'connect_feed_published_thread' =发表了,修改要到\source\plugin\qqconnect\discuz_plugin_qqconnect.xml135行修改; 后面的120是截取的标题的字数,可以根据自己需要设置;
$_t_content .= cutstr(strip_tags($html_content), 80);
//截取的简介内容,可以根据自己需要修改截取的内容简介数;
$_t_content .= ' ' . $url;
//$url是网址,后面可以添加自己需要的文字,修改方法是:$_t_content .= ' ' . $url.'你加的文字';二、回帖同步微博的格式:
回帖同步微博时的默认文字所在的代码分析
找到文件source/plugin/qqconnect/connect_feed.php 第226行


$_t_content = lang('plugin/qqconnect', 'connect_feed_iam');               
$_t_content .= '#' . cutstr($_G['setting']['bbname'], 20,'') . '#';
$_t_content .= lang('plugin/qqconnect', 'connect_feed_published_post', array('subject' => cutstr($thread['subject'], 120)));            
$_t_content .= cutstr(strip_tags($html_content), 80);               
$_t_content .= ' ' . $url;

详解如下
$_t_content = lang('plugin/qqconnect', 'connect_feed_iam');
// 'connect_feed_iam' ='我在';修改要到\source\plugin\qqconnect\discuz_plugin_qqconnect.xml134行修改;
$_t_content .= '#' . cutstr($_G['setting']['bbname'], 20,'') . '#';
//#网站名字#;修改要到 后台——》全局——》站点名称修改;
$_t_content .= lang('plugin/qqconnect', 'connect_feed_published_post', array('subject' => cutstr($thread['subject'], 120)));
// 'connect_feed_published_thread' =参与了xx的讨论修改要到\source\plugin\qqconnect\discuz_plugin_qqconnect.xml135行修改; 后面的120是截取的标题的字数,可以根据自己需要设置;
$_t_content .= cutstr(strip_tags($html_content), 80);
//截取的简介内容,可以根据自己需要修改截取的内容简介数;
$_t_content .= ' ' . $url;
//$url是网址,后面可以添加自己需要的文字,修改方法是:$_t_content .= ' ' . $url.'你加的文字';





三、分享到腾讯微博的格式:
分享到腾讯微博默认文字对应的代码分析:
找到文件source/plugin/qqconnect/spacecp.inc.php 的75行:
$share_message = lang('plugin/qqconnect', 'connect_spacecp_share_a_post', array('bbname' => cutstr($_G['setting']['bbname'], 20,''), 'subject' => cutstr($thread['subject'], 120), 'message' => cutstr(strip_tags(str_replace(' ', ' ', $html_content)), 80)));
$share_message = str_replace(array('\'', "\r\n", "\r", "\n"), array('"', '', '', ''), $share_message);代码详细分析:
$share_message = lang('plugin/qqconnect', 'connect_spacecp_share_a_post', array('bbname' => cutstr($_G['setting']['bbname'], 20,''), 'subject' => cutstr($thread['subject'], 120), 'message' => cutstr(strip_tags(str_replace(' ', ' ', $html_content)), 80)));
//'connect_spacecp_share_a_post' ='分享一个好帖#{bbname}#《{subject}》:{message}',详情修改是要到\source\plugin\qqconnect\discuz_plugin_qqconnect.xml136行修改; {bbname}#《{subject}》:{message} 分别是网站名称,帖子主题名字,内容简介;
$share_message = str_replace(array('\'', "\r\n", "\r", "\n"), array('"', '', '', ''), $share_message);
//对一些字符格式过滤,如果要添加文字可以这样修改 $share_message改为$share_message.'你要的文字'。

页: [1]
查看完整版本: QQ互联发帖同步和分享到腾讯微博默认文字的代码分析