Archive for September, 2009
同步LiveSpaces的评论到WordPress
以前做了个同步LiveSpaces的评论到WordPress的插件(wp-livesync-comments),没想到MS把评论的Layout给改了,结果抓不到正确的数据,导致WordPress里出现很多没有内容的匿名评论。今天稍微花点时间,修改了一下插件,让它可以正常工作了。
以前的评论格式:
<item>
<title>Thomas Tsui</title>
<link>http://xutao1976.spaces.live.com/Blog/cns!9A12B4DCE20412E9!437.entry</link>
<description>原来我的游戏机是这样买的。谢谢老爸老妈还记得这么清楚。<img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-7344609181510135063&page=RSS%3a+Thomas+Tsui&referrer=" width="1px" height="1px" border="0" alt=""><img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;NA=1149&amp;PI=73329&amp;RF=&amp;DI=3919&amp;PS=85545&amp;TP=xutao1976.spaces.live.com&amp;GT1=xutao1976"></description>
<guid isPermaLink=”false”>cns!9A12B4DCE20412E9!440</guid>
<pubDate>Tue, 20 Jan 2009 23:22:10 GMT</pubDate>
<msn:type>blogcomments</msn:type>
<live:type>blogcomments</live:type>
<live:typelabel>Blog Comments</live:typelabel>
<cf:itemRSS>http://xutao1976.spaces.live.com/blog/cns!9A12B4DCE20412E9!437/comments/feed.rss</cf:itemRSS>
<live:authorName>Thomas Tsui</live:authorName>
<live:authorCid>-7344609181510135063</live:authorCid>
<live:commentBody>原来我的游戏机是这样买的。谢谢老爸老妈还记得这么清楚。</live:commentBody>
</item>
现在的评论格式:
<item>
<guid isPermaLink=”false”>9A12B4DCE20412E9!440</guid>
<title>Thomas Tsui</title>
<description>原来我的游戏机是这样买的。谢谢老爸老妈还记得这么清楚。</description>
<pubDate>Tue, 20 Jan 2009 23:22:10 Z</pubDate>
<link>http://xutao1976.spaces.live.com/Blog/cns!9A12B4DCE20412E9!437.entry</link>
<live:type>blogcomment</live:type>
<live:typelabel>Blog Comment</live:typelabel>
<live:id>-7344609181510135063</live:id>
</item>
修改代码很简单。修复数据稍微麻烦一点。
1.在comments表里删除空评论。
DELETE FROM `wp_comments` WHERE `comment_author` = ‘ ‘ and `comment_content` = ‘ ‘;
2.在options表里删除wp_msnsync_comment_id
DELETE FROM `wp_options` WHERE `option_name` = ‘wp_msnsync_comment_id’;
这里是将所有以前同步过来的评论的ID全部删掉,但是实际的评论没有删除,所以下次同步的时候,会导致以前的评论重复。最好的方法是修改option_value里面的值,只将空评论的ID删除。不过我对MySQL不熟,不知道如何更新Key-Value Pair的项目,暂时也没时间去研究这个,以后再说了。
3.重新同步所有评论。


