CommentApi.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. #region Apache License Version 2.0
  2. /*----------------------------------------------------------------
  3. Copyright 2019 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
  4. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
  5. except in compliance with the License. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software distributed under the
  8. License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  9. either express or implied. See the License for the specific language governing permissions
  10. and limitations under the License.
  11. Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
  12. ----------------------------------------------------------------*/
  13. #endregion Apache License Version 2.0
  14. /*----------------------------------------------------------------
  15. Copyright (C) 2019 Senparc
  16. 文件名:CommentApi.cs
  17. 文件功能描述:评论数据管理
  18. 创建标识:Senparc - 20180131
  19. 修改标识:Senparc - 20180318
  20. 修改描述:v14.10.6 完善“查看指定文章的评论数据”接口(CommentApi.List())的返回结果数据
  21. ----------------------------------------------------------------*/
  22. /*
  23. API地址:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1494572718_WzHIY
  24. */
  25. using Senparc.CO2NET.Helpers.Serializers;
  26. using Senparc.NeuChar;
  27. using Senparc.Weixin.CommonAPIs;
  28. using Senparc.Weixin.Entities;
  29. using Senparc.Weixin.Helpers;
  30. using Senparc.Weixin.MP.AdvancedAPIs.Comment.CommentJson;
  31. using System;
  32. using System.Collections.Generic;
  33. using System.Linq;
  34. using System.Text;
  35. using System.Threading.Tasks;
  36. namespace Senparc.Weixin.MP.AdvancedAPIs
  37. {
  38. /// <summary>
  39. /// 评论数据管理
  40. /// </summary>
  41. public static class CommentApi
  42. {
  43. #region 同步方法
  44. /// <summary>
  45. /// 打开已群发文章评论(新增接口)
  46. /// </summary>
  47. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  48. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  49. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  50. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  51. /// <returns></returns>
  52. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.Open", true)]
  53. public static WxJsonResult Open(string accessTokenOrAppId, uint msg_data_id, uint? index, int timeOut = Config.TIME_OUT)
  54. {
  55. return ApiHandlerWapper.TryCommonApi(accessToken =>
  56. {
  57. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/open?access_token={0}";
  58. var data = new
  59. {
  60. msg_data_id = msg_data_id,
  61. index = index
  62. };
  63. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  64. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  65. }, accessTokenOrAppId);
  66. }
  67. /// <summary>
  68. /// 关闭已群发文章评论(新增接口)
  69. /// </summary>
  70. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  71. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  72. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  73. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  74. /// <returns></returns>
  75. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.Close", true)]
  76. public static WxJsonResult Close(string accessTokenOrAppId, uint msg_data_id, uint? index, int timeOut = Config.TIME_OUT)
  77. {
  78. return ApiHandlerWapper.TryCommonApi(accessToken =>
  79. {
  80. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/close?access_token={0}";
  81. var data = new
  82. {
  83. msg_data_id = msg_data_id,
  84. index = index
  85. };
  86. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  87. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  88. }, accessTokenOrAppId);
  89. }
  90. /// <summary>
  91. /// 查看指定文章的评论数据(新增接口)
  92. /// </summary>
  93. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  94. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  95. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  96. /// <param name="begin">起始位置</param>
  97. /// <param name="count">获取数目(>=50会被拒绝)</param>
  98. /// <param name="type">type=0 普通评论&精选评论 type=1 普通评论 type=2 精选评论</param>
  99. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  100. /// <returns></returns>
  101. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.List", true)]
  102. public static ListResultJson List(string accessTokenOrAppId, uint msg_data_id, uint? index, uint begin, uint count, uint type, int timeOut = Config.TIME_OUT)
  103. {
  104. //返回JSON:
  105. /*
  106. {
  107. "errcode": 0,
  108. "errmsg": "ok",
  109. "comment": [
  110. {
  111. "user_comment_id": 9,
  112. "create_time": 1521255525,
  113. "content": "如果有什么大考验的话可能会发现自己啥都没改都白扯了吧",
  114. "comment_type": 0,
  115. "openid": "oufSm0Xw0nhuha_nWD6AfiZ3rgvA",
  116. "reply" :
  117. {
  118. "content" : "CONTENT",
  119. "create_time" : 1521265525
  120. }
  121. }
  122. ],
  123. "total": 1
  124. }
  125. */
  126. return ApiHandlerWapper.TryCommonApi(accessToken =>
  127. {
  128. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/list?access_token={0}";
  129. var data = new
  130. {
  131. msg_data_id = msg_data_id,
  132. index = index,
  133. begin = begin,
  134. count = count,
  135. type = type
  136. };
  137. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  138. return CommonJsonSend.Send<ListResultJson>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  139. }, accessTokenOrAppId);
  140. }
  141. /// <summary>
  142. /// 将评论标记精选(新增接口)
  143. /// </summary>
  144. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  145. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  146. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  147. /// <param name="user_comment_id">用户评论id</param>
  148. /// <param name="timeOut"></param>
  149. /// <returns></returns>
  150. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.MarkElect", true)]
  151. public static WxJsonResult MarkElect(string accessTokenOrAppId, uint msg_data_id, uint? index, uint user_comment_id, int timeOut = Config.TIME_OUT)
  152. {
  153. return ApiHandlerWapper.TryCommonApi(accessToken =>
  154. {
  155. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/markelect?access_token={0}";
  156. var data = new
  157. {
  158. msg_data_id = msg_data_id,
  159. index = index,
  160. user_comment_id = user_comment_id,
  161. };
  162. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  163. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  164. }, accessTokenOrAppId);
  165. }
  166. /// <summary>
  167. /// 将评论取消精选(新增接口)
  168. /// </summary>
  169. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  170. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  171. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  172. /// <param name="user_comment_id">用户评论id</param>
  173. /// <param name="timeOut"></param>
  174. /// <returns></returns>
  175. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.UnmarkElect", true)]
  176. public static WxJsonResult UnmarkElect(string accessTokenOrAppId, uint msg_data_id, uint? index, uint user_comment_id, int timeOut = Config.TIME_OUT)
  177. {
  178. return ApiHandlerWapper.TryCommonApi(accessToken =>
  179. {
  180. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/unmarkelect?access_token={0}";
  181. var data = new
  182. {
  183. msg_data_id = msg_data_id,
  184. index = index,
  185. user_comment_id = user_comment_id,
  186. };
  187. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  188. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  189. }, accessTokenOrAppId);
  190. }
  191. /// <summary>
  192. /// 删除评论(新增接口)
  193. /// </summary>
  194. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  195. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  196. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  197. /// <param name="user_comment_id">用户评论id</param>
  198. /// <param name="timeOut"></param>
  199. /// <returns></returns>
  200. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.Delete", true)]
  201. public static WxJsonResult Delete(string accessTokenOrAppId, uint msg_data_id, uint? index, uint user_comment_id, int timeOut = Config.TIME_OUT)
  202. {
  203. return ApiHandlerWapper.TryCommonApi(accessToken =>
  204. {
  205. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/delete?access_token={0}";
  206. var data = new
  207. {
  208. msg_data_id = msg_data_id,
  209. index = index,
  210. user_comment_id = user_comment_id,
  211. };
  212. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  213. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  214. }, accessTokenOrAppId);
  215. }
  216. /// <summary>
  217. /// 回复评论(新增接口)
  218. /// </summary>
  219. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  220. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  221. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  222. /// <param name="user_comment_id">用户评论id</param>
  223. /// <param name="content">回复内容</param>
  224. /// <param name="timeOut"></param>
  225. /// <returns></returns>
  226. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.ReplyAdd", true)]
  227. public static WxJsonResult ReplyAdd(string accessTokenOrAppId, uint msg_data_id, uint? index, uint user_comment_id, string content, int timeOut = Config.TIME_OUT)
  228. {
  229. return ApiHandlerWapper.TryCommonApi(accessToken =>
  230. {
  231. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/reply/add?access_token={0}";
  232. var data = new
  233. {
  234. msg_data_id = msg_data_id,
  235. index = index,
  236. user_comment_id = user_comment_id,
  237. };
  238. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  239. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  240. }, accessTokenOrAppId);
  241. }
  242. /// <summary>
  243. /// 删除回复(新增接口)
  244. /// </summary>
  245. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  246. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  247. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  248. /// <param name="user_comment_id">用户评论id</param>
  249. /// <param name="content">回复内容</param>
  250. /// <param name="timeOut"></param>
  251. /// <returns></returns>
  252. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.ReplyDelete", true)]
  253. public static WxJsonResult ReplyDelete(string accessTokenOrAppId, uint msg_data_id, uint? index, uint user_comment_id, string content, int timeOut = Config.TIME_OUT)
  254. {
  255. return ApiHandlerWapper.TryCommonApi(accessToken =>
  256. {
  257. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/reply/delete?access_token={0}";
  258. var data = new
  259. {
  260. msg_data_id = msg_data_id,
  261. index = index,
  262. user_comment_id = user_comment_id,
  263. };
  264. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  265. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  266. }, accessTokenOrAppId);
  267. }
  268. #endregion
  269. #if !NET35 && !NET40
  270. #region 异步方法
  271. /// <summary>
  272. ///【异步方法】 打开已群发文章评论(新增接口)
  273. /// </summary>
  274. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  275. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  276. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  277. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  278. /// <returns></returns>
  279. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.OpenAsync", true)]
  280. public static async Task<WxJsonResult> OpenAsync(string accessTokenOrAppId, uint msg_data_id, uint? index, int timeOut = Config.TIME_OUT)
  281. {
  282. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  283. {
  284. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/open?access_token={0}";
  285. var data = new
  286. {
  287. msg_data_id = msg_data_id,
  288. index = index
  289. };
  290. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  291. return await CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  292. }, accessTokenOrAppId);
  293. }
  294. /// <summary>
  295. /// 【异步方法】关闭已群发文章评论(新增接口)
  296. /// </summary>
  297. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  298. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  299. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  300. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  301. /// <returns></returns>
  302. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.CloseAsync", true)]
  303. public static Task<WxJsonResult> CloseAsync(string accessTokenOrAppId, uint msg_data_id, uint? index, int timeOut = Config.TIME_OUT)
  304. {
  305. return ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  306. {
  307. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/close?access_token={0}";
  308. var data = new
  309. {
  310. msg_data_id = msg_data_id,
  311. index = index
  312. };
  313. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  314. return await CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  315. }, accessTokenOrAppId);
  316. }
  317. /// <summary>
  318. /// 【异步方法】查看指定文章的评论数据(新增接口)
  319. /// </summary>
  320. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  321. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  322. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  323. /// <param name="begin">起始位置</param>
  324. /// <param name="count">获取数目(>=50会被拒绝)</param>
  325. /// <param name="type">type=0 普通评论&精选评论 type=1 普通评论 type=2 精选评论</param>
  326. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  327. /// <returns></returns>
  328. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.ListAsync", true)]
  329. public static Task<ListResultJson> ListAsync(string accessTokenOrAppId, uint msg_data_id, uint? index, uint begin, uint count, uint type, int timeOut = Config.TIME_OUT)
  330. {
  331. //返回JSON:
  332. /*
  333. {
  334. "errcode": 0,
  335. "errmsg": "ok",
  336. "comment": [
  337. {
  338. "user_comment_id": 9,
  339. "create_time": 1521255525,
  340. "content": "如果有什么大考验的话可能会发现自己啥都没改都白扯了吧",
  341. "comment_type": 0,
  342. "openid": "oufSm0Xw0nhuha_nWD6AfiZ3rgvA"
  343. }
  344. ],
  345. "total": 1
  346. }
  347. */
  348. return ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  349. {
  350. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/list?access_token={0}";
  351. var data = new
  352. {
  353. msg_data_id = msg_data_id,
  354. index = index,
  355. begin = begin,
  356. count = count,
  357. type = type
  358. };
  359. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  360. return CommonJsonSend.Send<ListResultJson>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  361. }, accessTokenOrAppId);
  362. }
  363. /// <summary>
  364. /// 【异步方法】将评论标记精选(新增接口)
  365. /// </summary>
  366. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  367. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  368. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  369. /// <param name="user_comment_id">用户评论id</param>
  370. /// <param name="timeOut"></param>
  371. /// <returns></returns>
  372. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.MarkElectAsync", true)]
  373. public static Task<WxJsonResult> MarkElectAsync(string accessTokenOrAppId, uint msg_data_id, uint? index, uint user_comment_id, int timeOut = Config.TIME_OUT)
  374. {
  375. return ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  376. {
  377. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/markelect?access_token={0}";
  378. var data = new
  379. {
  380. msg_data_id = msg_data_id,
  381. index = index,
  382. user_comment_id = user_comment_id,
  383. };
  384. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  385. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  386. }, accessTokenOrAppId);
  387. }
  388. /// <summary>
  389. /// 【异步方法】将评论取消精选(新增接口)
  390. /// </summary>
  391. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  392. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  393. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  394. /// <param name="user_comment_id">用户评论id</param>
  395. /// <param name="timeOut"></param>
  396. /// <returns></returns>
  397. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.UnmarkElectAsync", true)]
  398. public static Task<WxJsonResult> UnmarkElectAsync(string accessTokenOrAppId, uint msg_data_id, uint? index, uint user_comment_id, int timeOut = Config.TIME_OUT)
  399. {
  400. return ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  401. {
  402. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/unmarkelect?access_token={0}";
  403. var data = new
  404. {
  405. msg_data_id = msg_data_id,
  406. index = index,
  407. user_comment_id = user_comment_id,
  408. };
  409. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  410. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  411. }, accessTokenOrAppId);
  412. }
  413. /// <summary>
  414. /// 【异步方法】删除评论(新增接口)
  415. /// </summary>
  416. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  417. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  418. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  419. /// <param name="user_comment_id">用户评论id</param>
  420. /// <param name="timeOut"></param>
  421. /// <returns></returns>
  422. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.DeleteAsync", true)]
  423. public static Task<WxJsonResult> DeleteAsync(string accessTokenOrAppId, uint msg_data_id, uint? index, uint user_comment_id, int timeOut = Config.TIME_OUT)
  424. {
  425. return ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  426. {
  427. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/delete?access_token={0}";
  428. var data = new
  429. {
  430. msg_data_id = msg_data_id,
  431. index = index,
  432. user_comment_id = user_comment_id,
  433. };
  434. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  435. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  436. }, accessTokenOrAppId);
  437. }
  438. /// <summary>
  439. /// 【异步方法】回复评论(新增接口)
  440. /// </summary>
  441. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  442. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  443. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  444. /// <param name="user_comment_id">用户评论id</param>
  445. /// <param name="content">回复内容</param>
  446. /// <param name="timeOut"></param>
  447. /// <returns></returns>
  448. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.ReplyAddAsync", true)]
  449. public static Task<WxJsonResult> ReplyAddAsync(string accessTokenOrAppId, uint msg_data_id, uint? index, uint user_comment_id, string content, int timeOut = Config.TIME_OUT)
  450. {
  451. return ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  452. {
  453. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/reply/add?access_token={0}";
  454. var data = new
  455. {
  456. msg_data_id = msg_data_id,
  457. index = index,
  458. user_comment_id = user_comment_id,
  459. };
  460. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  461. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  462. }, accessTokenOrAppId);
  463. }
  464. /// <summary>
  465. /// 【异步方法】删除回复(新增接口)
  466. /// </summary>
  467. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  468. /// <param name="msg_data_id">群发返回的msg_data_id</param>
  469. /// <param name="index">(非必填)多图文时,用来指定第几篇图文,从0开始,不带默认返回该msg_data_id的第一篇图文</param>
  470. /// <param name="user_comment_id">用户评论id</param>
  471. /// <param name="content">回复内容</param>
  472. /// <param name="timeOut"></param>
  473. /// <returns></returns>
  474. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CommentApi.ReplyDeleteAsync", true)]
  475. public static Task<WxJsonResult> ReplyDeleteAsync(string accessTokenOrAppId, uint msg_data_id, uint? index, uint user_comment_id, string content, int timeOut = Config.TIME_OUT)
  476. {
  477. return ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  478. {
  479. var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/reply/delete?access_token={0}";
  480. var data = new
  481. {
  482. msg_data_id = msg_data_id,
  483. index = index,
  484. user_comment_id = user_comment_id,
  485. };
  486. JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
  487. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  488. }, accessTokenOrAppId);
  489. }
  490. #endregion
  491. #endif
  492. }
  493. }