帝国cms在将多说评论数据反向同步回网站本地的一些笔记

时间:2016-08-25 23:43:23

分类:帝国教程

最近需要将一个帝国cms网站的多说评论数据同步到本地,主要原因是评论数据全部存放在多说服务器,如果哪天多说关闭会全部丢失,另外多说似乎越来越沉寂了。

前边的接口文件书写不再详述,就是检测post,并判断是否正确,传值正确则进行下面的读取写入操作。这方面可以参考官方文档。

http://dev.duoshuo.com/docs/50037b11b66af78d0c000009

文档中写明有评论时多说会向预留的地址进行post,但实际测试时没有收到任何post或者get动作,这多说是临时故障还是这方面功能已经不可用就不得而知了。还是赶快把评论搬回来吧。

官方给出的接口示例http://api.duoshuo.com/threads/listPosts.json?order=asc&thread_key=article1&short_name=official&page=1&limit=10

其中标红的部分修改为自己的文章id和短名称,根据测试,我们获得了下面的数据。

而在这里边,我们发现了一个非常严重的问题,多说只保存了文章id,而没有保存栏目id。这对于多使用帝国cms的多数据表功能时,栏目多,文章也多的情况下,不知道是否会出现问题。

不过json数据还算详细,我们可以对数据自由组合然后写入帝国cms的评论数据表了。

折叠XML/HTML 代码
  1. {  
  2.     "options": {  
  3.         "formPosition": "bottom",  
  4.         "order": "asc",  
  5.         "limit": 50,  
  6.         "hot_posts": 3,  
  7.         "max_depth": 1,  
  8.         "show_context": false,  
  9.         "like_thread_enabled": true,  
  10.         "parse_html_enabled": false,  
  11.         "show_weibo": true,  
  12.         "show_qqt": true,  
  13.         "show_reposts": true,  
  14.         "deny_anonymous": false,  
  15.         "auth_in_win": true,  
  16.         "require_guest_email": true,  
  17.         "require_guest_url": false,  
  18.         "use_smilies": true,  
  19.         "use_images": false,  
  20.         "poweredby_text": "dy1950正在使用多说",  
  21.         "mzadx_id": null  
  22.     },  
  23.     "response": [  
  24.         "6322763823199552258",  
  25.         "6322768253043081985",  
  26.         "6322769681241342722",  
  27.         "6322770460303950594",  
  28.         "6322770797345637121",  
  29.         "6322772209777509121",  
  30.         "6322772942212039426",  
  31.         "6322773799255147265"  
  32.     ],  
  33.     "hotPosts": [],  
  34.     "parentPosts": {  
  35.         "6322763823199552258": {  
  36.             "post_id": "6322763823199552258",  
  37.             "thread_id": "6322763805424091905",  
  38.             "status": "approved",  
  39.             "source": "duoshuo",  
  40.             "type": "duoshuo",  
  41.             "message": "11111111111111111111",  
  42.             "created_at": "2016-08-25T21:52:50+08:00",  
  43.             "privileges": [],  
  44.             "parent_id": 0,  
  45.             "root_id": 0,  
  46.             "reposts": 0,  
  47.             "comments": 0,  
  48.             "author_id": "12210120",  
  49.             "agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER",  
  50.             "likes": 0,  
  51.             "dislikes": 0,  
  52.             "reports": 0,  
  53.             "parents": [],  
  54.             "author": {  
  55.                 "user_id": "12210120",  
  56.                 "name": "This is he.",  
  57.                 "avatar_url": "http://q.qlogo.cn/qqapp/100229475/FD187BD3754E35AF97433758AD6A792B/100",  
  58.                 "url": "",  
  59.                 "threads": "",  
  60.                 "comments": "22",  
  61.                 "weibo_uid": "",  
  62.                 "qq_uid": "FD187BD3754E35AF97433758AD6A792B",  
  63.                 "renren_uid": "",  
  64.                 "kaixin_uid": "",  
  65.                 "douban_uid": "",  
  66.                 "netease_uid": "",  
  67.                 "sohu_uid": "",  
  68.                 "baidu_uid": "",  
  69.                 "msn_uid": "",  
  70.                 "google_uid": "",  
  71.                 "taobao_uid": ""  
  72.             },  
  73.             "ip": "144.12.248.56",  
  74.             "iplocation": "山东",  
  75.             "is_top": 0  
  76.         },  
  77.         "6322768253043081985": {  
  78.             "post_id": "6322768253043081985",  
  79.             "thread_id": "6322763805424091905",  
  80.             "status": "approved",  
  81.             "source": "duoshuo",  
  82.             "type": "duoshuo",  
  83.             "message": "12121212121212",  
  84.             "created_at": "2016-08-25T22:10:02+08:00",  
  85.             "privileges": [],  
  86.             "parent_id": 0,  
  87.             "root_id": 0,  
  88.             "reposts": 0,  
  89.             "comments": 0,  
  90.             "author_id": "12210120",  
  91.             "agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER",  
  92.             "likes": 0,  
  93.             "dislikes": 0,  
  94.             "reports": 0,  
  95.             "parents": [],  
  96.             "author": {  
  97.                 "user_id": "12210120",  
  98.                 "name": "This is he.",  
  99.                 "avatar_url": "http://q.qlogo.cn/qqapp/100229475/FD187BD3754E35AF97433758AD6A792B/100",  
  100.                 "url": "",  
  101.                 "threads": "",  
  102.                 "comments": "22",  
  103.                 "weibo_uid": "",  
  104.                 "qq_uid": "FD187BD3754E35AF97433758AD6A792B",  
  105.                 "renren_uid": "",  
  106.                 "kaixin_uid": "",  
  107.                 "douban_uid": "",  
  108.                 "netease_uid": "",  
  109.                 "sohu_uid": "",  
  110.                 "baidu_uid": "",  
  111.                 "msn_uid": "",  
  112.                 "google_uid": "",  
  113.                 "taobao_uid": ""  
  114.             },  
  115.             "ip": "144.12.248.56",  
  116.             "iplocation": "山东",  
  117.             "is_top": 0  
  118.         },  
  119.         "6322769681241342722": {  
  120.             "post_id": "6322769681241342722",  
  121.             "thread_id": "6322763805424091905",  
  122.             "status": "approved",  
  123.             "source": "duoshuo",  
  124.             "type": "duoshuo",  
  125.             "message": "啊啊啊啊啊",  
  126.             "created_at": "2016-08-25T22:15:34+08:00",  
  127.             "privileges": [],  
  128.             "parent_id": 0,  
  129.             "root_id": 0,  
  130.             "reposts": 0,  
  131.             "comments": 0,  
  132.             "author_id": "12210120",  
  133.             "agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER",  
  134.             "likes": 0,  
  135.             "dislikes": 0,  
  136.             "reports": 0,  
  137.             "parents": [],  
  138.             "author": {  
  139.                 "user_id": "12210120",  
  140.                 "name": "This is he.",  
  141.                 "avatar_url": "http://q.qlogo.cn/qqapp/100229475/FD187BD3754E35AF97433758AD6A792B/100",  
  142.                 "url": "",  
  143.                 "threads": "",  
  144.                 "comments": "22",  
  145.                 "weibo_uid": "",  
  146.                 "qq_uid": "FD187BD3754E35AF97433758AD6A792B",  
  147.                 "renren_uid": "",  
  148.                 "kaixin_uid": "",  
  149.                 "douban_uid": "",  
  150.                 "netease_uid": "",  
  151.                 "sohu_uid": "",  
  152.                 "baidu_uid": "",  
  153.                 "msn_uid": "",  
  154.                 "google_uid": "",  
  155.                 "taobao_uid": ""  
  156.             },  
  157.             "ip": "144.12.248.56",  
  158.             "iplocation": "山东",  
  159.             "is_top": 0  
  160.         },  
  161.         "6322770460303950594": {  
  162.             "post_id": "6322770460303950594",  
  163.             "thread_id": "6322763805424091905",  
  164.             "status": "approved",  
  165.             "source": "duoshuo",  
  166.             "type": "duoshuo",  
  167.             "message": "11111111111111111",  
  168.             "created_at": "2016-08-25T22:18:35+08:00",  
  169.             "privileges": [],  
  170.             "parent_id": 0,  
  171.             "root_id": 0,  
  172.             "reposts": 0,  
  173.             "comments": 0,  
  174.             "author_id": "12210120",  
  175.             "agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER",  
  176.             "likes": 0,  
  177.             "dislikes": 0,  
  178.             "reports": 0,  
  179.             "parents": [],  
  180.             "author": {  
  181.                 "user_id": "12210120",  
  182.                 "name": "This is he.",  
  183.                 "avatar_url": "http://q.qlogo.cn/qqapp/100229475/FD187BD3754E35AF97433758AD6A792B/100",  
  184.                 "url": "",  
  185.                 "threads": "",  
  186.                 "comments": "22",  
  187.                 "weibo_uid": "",  
  188.                 "qq_uid": "FD187BD3754E35AF97433758AD6A792B",  
  189.                 "renren_uid": "",  
  190.                 "kaixin_uid": "",  
  191.                 "douban_uid": "",  
  192.                 "netease_uid": "",  
  193.                 "sohu_uid": "",  
  194.                 "baidu_uid": "",  
  195.                 "msn_uid": "",  
  196.                 "google_uid": "",  
  197.                 "taobao_uid": ""  
  198.             },  
  199.             "ip": "144.12.248.56",  
  200.             "iplocation": "山东",  
  201.             "is_top": 0  
  202.         },  
  203.         "6322770797345637121": {  
  204.             "post_id": "6322770797345637121",  
  205.             "thread_id": "6322763805424091905",  
  206.             "status": "approved",  
  207.             "source": "duoshuo",  
  208.             "type": "duoshuo",  
  209.             "message": "22222222222222222",  
  210.             "created_at": "2016-08-25T22:19:54+08:00",  
  211.             "privileges": [],  
  212.             "parent_id": 0,  
  213.             "root_id": 0,  
  214.             "reposts": 0,  
  215.             "comments": 0,  
  216.             "author_id": "12210120",  
  217.             "agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER",  
  218.             "likes": 0,  
  219.             "dislikes": 0,  
  220.             "reports": 0,  
  221.             "parents": [],  
  222.             "author": {  
  223.                 "user_id": "12210120",  
  224.                 "name": "This is he.",  
  225.                 "avatar_url": "http://q.qlogo.cn/qqapp/100229475/FD187BD3754E35AF97433758AD6A792B/100",  
  226.                 "url": "",  
  227.                 "threads": "",  
  228.                 "comments": "22",  
  229.                 "weibo_uid": "",  
  230.                 "qq_uid": "FD187BD3754E35AF97433758AD6A792B",  
  231.                 "renren_uid": "",  
  232.                 "kaixin_uid": "",  
  233.                 "douban_uid": "",  
  234.                 "netease_uid": "",  
  235.                 "sohu_uid": "",  
  236.                 "baidu_uid": "",  
  237.                 "msn_uid": "",  
  238.                 "google_uid": "",  
  239.                 "taobao_uid": ""  
  240.             },  
  241.             "ip": "144.12.248.56",  
  242.             "iplocation": "山东",  
  243.             "is_top": 0  
  244.         },  
  245.         "6322772209777509121": {  
  246.             "post_id": "6322772209777509121",  
  247.             "thread_id": "6322763805424091905",  
  248.             "status": "approved",  
  249.             "source": "duoshuo",  
  250.             "type": "duoshuo",  
  251.             "message": "11111111111",  
  252.             "created_at": "2016-08-25T22:25:23+08:00",  
  253.             "privileges": [],  
  254.             "parent_id": 0,  
  255.             "root_id": 0,  
  256.             "reposts": 0,  
  257.             "comments": 0,  
  258.             "author_id": "12210120",  
  259.             "agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER",  
  260.             "likes": 0,  
  261.             "dislikes": 0,  
  262.             "reports": 0,  
  263.             "parents": [],  
  264.             "author": {  
  265.                 "user_id": "12210120",  
  266.                 "name": "This is he.",  
  267.                 "avatar_url": "http://q.qlogo.cn/qqapp/100229475/FD187BD3754E35AF97433758AD6A792B/100",  
  268.                 "url": "",  
  269.                 "threads": "",  
  270.                 "comments": "22",  
  271.                 "weibo_uid": "",  
  272.                 "qq_uid": "FD187BD3754E35AF97433758AD6A792B",  
  273.                 "renren_uid": "",  
  274.                 "kaixin_uid": "",  
  275.                 "douban_uid": "",  
  276.                 "netease_uid": "",  
  277.                 "sohu_uid": "",  
  278.                 "baidu_uid": "",  
  279.                 "msn_uid": "",  
  280.                 "google_uid": "",  
  281.                 "taobao_uid": ""  
  282.             },  
  283.             "ip": "144.12.248.56",  
  284.             "iplocation": "山东",  
  285.             "is_top": 0  
  286.         },  
  287.         "6322772942212039426": {  
  288.             "post_id": "6322772942212039426",  
  289.             "thread_id": "6322763805424091905",  
  290.             "status": "approved",  
  291.             "source": "duoshuo",  
  292.             "type": "duoshuo",  
  293.             "message": "5555555555",  
  294.             "created_at": "2016-08-25T22:28:13+08:00",  
  295.             "privileges": [],  
  296.             "parent_id": 0,  
  297.             "root_id": 0,  
  298.             "reposts": 0,  
  299.             "comments": 0,  
  300.             "author_id": "12210120",  
  301.             "agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER",  
  302.             "likes": 0,  
  303.             "dislikes": 0,  
  304.             "reports": 0,  
  305.             "parents": [],  
  306.             "author": {  
  307.                 "user_id": "12210120",  
  308.                 "name": "This is he.",  
  309.                 "avatar_url": "http://q.qlogo.cn/qqapp/100229475/FD187BD3754E35AF97433758AD6A792B/100",  
  310.                 "url": "",  
  311.                 "threads": "",  
  312.                 "comments": "22",  
  313.                 "weibo_uid": "",  
  314.                 "qq_uid": "FD187BD3754E35AF97433758AD6A792B",  
  315.                 "renren_uid": "",  
  316.                 "kaixin_uid": "",  
  317.                 "douban_uid": "",  
  318.                 "netease_uid": "",  
  319.                 "sohu_uid": "",  
  320.                 "baidu_uid": "",  
  321.                 "msn_uid": "",  
  322.                 "google_uid": "",  
  323.                 "taobao_uid": ""  
  324.             },  
  325.             "ip": "144.12.248.56",  
  326.             "iplocation": "山东",  
  327.             "is_top": 0  
  328.         },  
  329.         "6322773799255147265": {  
  330.             "post_id": "6322773799255147265",  
  331.             "thread_id": "6322763805424091905",  
  332.             "status": "approved",  
  333.             "source": "duoshuo",  
  334.             "type": "duoshuo",  
  335.             "message": " <img src=\"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/0b/tootha_org.gif\" alt=\"[嘻嘻]\" title=\"[嘻嘻]\" class=\"ds-smiley\" />  <img src=\"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/a6/x_org.gif\" alt=\"[嘘]\" title=\"[嘘]\" class=\"ds-smiley\" /> ",  
  336.             "created_at": "2016-08-25T22:31:33+08:00",  
  337.             "privileges": [],  
  338.             "parent_id": 0,  
  339.             "root_id": 0,  
  340.             "reposts": 0,  
  341.             "comments": 0,  
  342.             "author_id": "12210120",  
  343.             "agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER",  
  344.             "likes": 0,  
  345.             "dislikes": 0,  
  346.             "reports": 0,  
  347.             "parents": [],  
  348.             "author": {  
  349.                 "user_id": "12210120",  
  350.                 "name": "This is he.",  
  351.                 "avatar_url": "http://q.qlogo.cn/qqapp/100229475/FD187BD3754E35AF97433758AD6A792B/100",  
  352.                 "url": "",  
  353.                 "threads": "",  
  354.                 "comments": "22",  
  355.                 "weibo_uid": "",  
  356.                 "qq_uid": "FD187BD3754E35AF97433758AD6A792B",  
  357.                 "renren_uid": "",  
  358.                 "kaixin_uid": "",  
  359.                 "douban_uid": "",  
  360.                 "netease_uid": "",  
  361.                 "sohu_uid": "",  
  362.                 "baidu_uid": "",  
  363.                 "msn_uid": "",  
  364.                 "google_uid": "",  
  365.                 "taobao_uid": ""  
  366.             },  
  367.             "ip": "144.12.248.56",  
  368.             "iplocation": "山东",  
  369.             "is_top": 0  
  370.         }  
  371.     },  
  372.     "users": {  
  373.         "12210120": {  
  374.             "user_id": "12210120",  
  375.             "name": "This is he.",  
  376.             "avatar_url": "http://q.qlogo.cn/qqapp/100229475/FD187BD3754E35AF97433758AD6A792B/100",  
  377.             "url": "",  
  378.             "threads": "",  
  379.             "comments": "22",  
  380.             "weibo_uid": "",  
  381.             "qq_uid": "FD187BD3754E35AF97433758AD6A792B",  
  382.             "renren_uid": "",  
  383.             "kaixin_uid": "",  
  384.             "douban_uid": "",  
  385.             "netease_uid": "",  
  386.             "sohu_uid": "",  
  387.             "baidu_uid": "",  
  388.             "msn_uid": "",  
  389.             "google_uid": "",  
  390.             "taobao_uid": ""  
  391.         }  
  392.     },  
  393.     "thread": {  
  394.         "thread_id": "6322763805424091905",  
  395.         "site_id": 1320536,  
  396.         "title": "美式极端/超能特工1280超清迅雷下载",  
  397.         "created_at": "2016-08-25T21:52:46+08:00",  
  398.         "thread_key": "11510",  
  399.         "url": "http://localhost/dianying/11510.html",  
  400.         "meta": [],  
  401.         "agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER",  
  402.         "source": "duoshuo",  
  403.         "author_id": "0",  
  404.         "comments": 8,  
  405.         "dislikes": 0,  
  406.         "likes": 0,  
  407.         "reposts": 0,  
  408.         "views": 0,  
  409.         "post_enable": 1  
  410.     },  
  411.     "cursor": {  
  412.         "total": 8,  
  413.         "pages": 1  
  414.     },  
  415.     "code": 0  
  416. }  

 

 

相关文章

相关推荐

为帝国CMS用户提供动力

Copyright © 2016 CmsDX.com All Rights Reserved.