AnalysisApi.cs 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  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. 文件名:AnalysisAPI.cs
  17. 文件功能描述:分析数据接口
  18. 创建标识:Senparc - 20150211
  19. 修改标识:Senparc - 20150303
  20. 修改描述:整理接口
  21. 修改标识:Senparc - 20150312
  22. 修改描述:开放代理请求超时时间
  23. 修改标识:Senparc - 20160718
  24. 修改描述:将其接口增加了异步方法
  25. 修改标识:Senparc - 20170707
  26. 修改描述:v14.5.1 完善异步方法async/await
  27. ----------------------------------------------------------------*/
  28. /*
  29. 图文分析数据接口详见:http://mp.weixin.qq.com/wiki/8/c0453610fb5131d1fcb17b4e87c82050.html
  30. 接口分析数据接口详见:http://mp.weixin.qq.com/wiki/8/30ed81ae38cf4f977194bf1a5db73668.html
  31. 消息分析数据接口详见:http://mp.weixin.qq.com/wiki/12/32d42ad542f2e4fc8a8aa60e1bce9838.html
  32. 用户分析数据接口详见:http://mp.weixin.qq.com/wiki/3/ecfed6e1a0a03b5f35e5efac98e864b7.html
  33. */
  34. using System.Threading.Tasks;
  35. using Senparc.CO2NET;
  36. using Senparc.NeuChar;
  37. using Senparc.Weixin.CommonAPIs;
  38. using Senparc.Weixin.MP.AdvancedAPIs.Analysis;
  39. using Senparc.Weixin.MP.CommonAPIs;
  40. namespace Senparc.Weixin.MP.AdvancedAPIs
  41. {
  42. /// <summary>
  43. /// 分析数据接口
  44. /// 最大时间跨度是指一次接口调用时最大可获取数据的时间范围,如最大时间跨度为7是指最多一次性获取7天的数据。
  45. /// 注意:所有的日期请使用【yyyy-MM-dd】的格式
  46. /// </summary>
  47. public static class AnalysisApi
  48. {
  49. #region 同步方法
  50. #region 图文分析数据接口
  51. /// <summary>
  52. /// 获取图文群发每日数据(getarticlesummary)
  53. /// 最大时间跨度 1
  54. /// </summary>
  55. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  56. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  57. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  58. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  59. /// <returns></returns>
  60. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetArticleSummary", true)]
  61. public static AnalysisResultJson<ArticleSummaryItem> GetArticleSummary(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  62. {
  63. return ApiHandlerWapper.TryCommonApi(accessToken =>
  64. {
  65. string urlFormat = Config.ApiMpHost + "/datacube/getarticlesummary?access_token={0}";
  66. var data = new
  67. {
  68. begin_date = beginDate,
  69. end_date = endDate
  70. };
  71. return CommonJsonSend.Send<AnalysisResultJson<ArticleSummaryItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  72. }, accessTokenOrAppId);
  73. }
  74. /// <summary>
  75. /// 获取图文群发总数据(getarticletotal)
  76. /// 请注意,details中,每天对应的数值为该文章到该日为止的总量(而不是当日的量)
  77. /// 最大时间跨度 1
  78. /// </summary>
  79. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  80. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  81. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  82. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  83. /// <returns></returns>
  84. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetArticleTotal", true)]
  85. public static AnalysisResultJson<ArticleTotalItem> GetArticleTotal(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  86. {
  87. return ApiHandlerWapper.TryCommonApi(accessToken =>
  88. {
  89. string urlFormat = Config.ApiMpHost + "/datacube/getarticletotal?access_token={0}";
  90. var data = new
  91. {
  92. begin_date = beginDate,
  93. end_date = endDate
  94. };
  95. return CommonJsonSend.Send<AnalysisResultJson<ArticleTotalItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  96. }, accessTokenOrAppId);
  97. }
  98. /// <summary>
  99. /// 获取图文统计数据(getuserread)
  100. /// 最大时间跨度 3
  101. /// </summary>
  102. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  103. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  104. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  105. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  106. /// <returns></returns>
  107. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserRead", true)]
  108. public static AnalysisResultJson<UserReadItem> GetUserRead(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  109. {
  110. return ApiHandlerWapper.TryCommonApi(accessToken =>
  111. {
  112. string urlFormat = Config.ApiMpHost + "/datacube/getuserread?access_token={0}";
  113. var data = new
  114. {
  115. begin_date = beginDate,
  116. end_date = endDate
  117. };
  118. return CommonJsonSend.Send<AnalysisResultJson<UserReadItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  119. }, accessTokenOrAppId);
  120. }
  121. /// <summary>
  122. /// 获取图文统计分时数据(getuserreadhour)
  123. /// 最大时间跨度 1
  124. /// </summary>
  125. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  126. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  127. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  128. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  129. /// <returns></returns>
  130. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserReadHour", true)]
  131. public static AnalysisResultJson<UserReadHourItem> GetUserReadHour(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  132. {
  133. return ApiHandlerWapper.TryCommonApi(accessToken =>
  134. {
  135. string urlFormat = Config.ApiMpHost + "/datacube/getuserreadhour?access_token={0}";
  136. var data = new
  137. {
  138. begin_date = beginDate,
  139. end_date = endDate
  140. };
  141. return CommonJsonSend.Send<AnalysisResultJson<UserReadHourItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  142. }, accessTokenOrAppId);
  143. }
  144. /// <summary>
  145. /// 获取图文分享转发数据(getusershare)
  146. /// 最大时间跨度 7
  147. /// </summary>
  148. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  149. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  150. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  151. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  152. /// <returns></returns>
  153. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserShare", true)]
  154. public static AnalysisResultJson<UserShareItem> GetUserShare(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  155. {
  156. return ApiHandlerWapper.TryCommonApi(accessToken =>
  157. {
  158. string urlFormat = Config.ApiMpHost + "/datacube/getusershare?access_token={0}";
  159. var data = new
  160. {
  161. begin_date = beginDate,
  162. end_date = endDate
  163. };
  164. return CommonJsonSend.Send<AnalysisResultJson<UserShareItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  165. }, accessTokenOrAppId);
  166. }
  167. /// <summary>
  168. /// 获取图文分享转发分时数据(getusersharehour)
  169. /// 最大时间跨度 1
  170. /// </summary>
  171. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  172. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  173. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  174. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  175. /// <returns></returns>
  176. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserShareHour", true)]
  177. public static AnalysisResultJson<UserShareHourItem> GetUserShareHour(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  178. {
  179. return ApiHandlerWapper.TryCommonApi(accessToken =>
  180. {
  181. string urlFormat = Config.ApiMpHost + "/datacube/getusersharehour?access_token={0}";
  182. var data = new
  183. {
  184. begin_date = beginDate,
  185. end_date = endDate
  186. };
  187. return CommonJsonSend.Send<AnalysisResultJson<UserShareHourItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  188. }, accessTokenOrAppId);
  189. }
  190. #endregion
  191. #region 接口分析数据接口
  192. /// <summary>
  193. /// 获取接口分析数据(getinterfacesummary)
  194. /// 最大时间跨度 30
  195. /// </summary>
  196. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  197. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  198. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  199. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  200. /// <returns></returns>
  201. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetInterfaceSummary", true)]
  202. public static AnalysisResultJson<InterfaceSummaryItem> GetInterfaceSummary(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  203. {
  204. return ApiHandlerWapper.TryCommonApi(accessToken =>
  205. {
  206. string urlFormat = Config.ApiMpHost + "/datacube/getinterfacesummary?access_token={0}";
  207. var data = new
  208. {
  209. begin_date = beginDate,
  210. end_date = endDate
  211. };
  212. return CommonJsonSend.Send<AnalysisResultJson<InterfaceSummaryItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  213. }, accessTokenOrAppId);
  214. }
  215. /// <summary>
  216. /// 获取接口分析分时数据(getinterfacesummaryhour)
  217. /// 最大时间跨度 1
  218. /// </summary>
  219. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  220. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  221. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  222. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  223. /// <returns></returns>
  224. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetInterfaceSummaryHour", true)]
  225. public static AnalysisResultJson<InterfaceSummaryHourItem> GetInterfaceSummaryHour(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  226. {
  227. return ApiHandlerWapper.TryCommonApi(accessToken =>
  228. {
  229. string urlFormat = Config.ApiMpHost + "/datacube/getinterfacesummaryhour?access_token={0}";
  230. var data = new
  231. {
  232. begin_date = beginDate,
  233. end_date = endDate
  234. };
  235. return CommonJsonSend.Send<AnalysisResultJson<InterfaceSummaryHourItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  236. }, accessTokenOrAppId);
  237. }
  238. #endregion
  239. #region 消息分析数据接口
  240. /// <summary>
  241. /// 获取消息发送概况数据(getupstreammsg)
  242. /// 最大时间跨度 7
  243. /// </summary>
  244. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  245. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  246. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  247. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  248. /// <returns></returns>
  249. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsg", true)]
  250. public static AnalysisResultJson<UpStreamMsgItem> GetUpStreamMsg(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  251. {
  252. return ApiHandlerWapper.TryCommonApi(accessToken =>
  253. {
  254. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsg?access_token={0}";
  255. var data = new
  256. {
  257. begin_date = beginDate,
  258. end_date = endDate
  259. };
  260. return CommonJsonSend.Send<AnalysisResultJson<UpStreamMsgItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  261. }, accessTokenOrAppId);
  262. }
  263. /// <summary>
  264. /// 获取消息分送分时数据(getupstreammsghour)
  265. /// 最大时间跨度 1
  266. /// </summary>
  267. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  268. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  269. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  270. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  271. /// <returns></returns>
  272. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgHour", true)]
  273. public static AnalysisResultJson<UpStreamMsgHourItem> GetUpStreamMsgHour(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  274. {
  275. return ApiHandlerWapper.TryCommonApi(accessToken =>
  276. {
  277. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsghour?access_token={0}";
  278. var data = new
  279. {
  280. begin_date = beginDate,
  281. end_date = endDate
  282. };
  283. return CommonJsonSend.Send<AnalysisResultJson<UpStreamMsgHourItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  284. }, accessTokenOrAppId);
  285. }
  286. /// <summary>
  287. /// 获取消息发送周数据(getupstreammsgweek)
  288. /// 最大时间跨度 30
  289. /// </summary>
  290. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  291. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  292. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  293. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  294. /// <returns></returns>
  295. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgWeek", true)]
  296. public static AnalysisResultJson<UpStreamMsgWeekItem> GetUpStreamMsgWeek(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  297. {
  298. return ApiHandlerWapper.TryCommonApi(accessToken =>
  299. {
  300. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsgweek?access_token={0}";
  301. var data = new
  302. {
  303. begin_date = beginDate,
  304. end_date = endDate
  305. };
  306. return CommonJsonSend.Send<AnalysisResultJson<UpStreamMsgWeekItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  307. }, accessTokenOrAppId);
  308. }
  309. /// <summary>
  310. /// 获取消息发送月数据(getupstreammsgmonth)
  311. /// 最大时间跨度 30
  312. /// </summary>
  313. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  314. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  315. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  316. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  317. /// <returns></returns>
  318. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgMonth", true)]
  319. public static AnalysisResultJson<UpStreamMsgMonthItem> GetUpStreamMsgMonth(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  320. {
  321. return ApiHandlerWapper.TryCommonApi(accessToken =>
  322. {
  323. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsgmonth?access_token={0}";
  324. var data = new
  325. {
  326. begin_date = beginDate,
  327. end_date = endDate
  328. };
  329. return CommonJsonSend.Send<AnalysisResultJson<UpStreamMsgMonthItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  330. }, accessTokenOrAppId);
  331. }
  332. /// <summary>
  333. /// 获取消息发送分布数据(getupstreammsgdist)
  334. /// 最大时间跨度 15
  335. /// </summary>
  336. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  337. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  338. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  339. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  340. /// <returns></returns>
  341. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgDist", true)]
  342. public static AnalysisResultJson<UpStreamMsgDistItem> GetUpStreamMsgDist(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  343. {
  344. return ApiHandlerWapper.TryCommonApi(accessToken =>
  345. {
  346. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsgdist?access_token={0}";
  347. var data = new
  348. {
  349. begin_date = beginDate,
  350. end_date = endDate
  351. };
  352. return CommonJsonSend.Send<AnalysisResultJson<UpStreamMsgDistItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  353. }, accessTokenOrAppId);
  354. }
  355. /// <summary>
  356. /// 获取消息发送分布周数据(getupstreammsgdistweek)
  357. /// 最大时间跨度 30
  358. /// </summary>
  359. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  360. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  361. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  362. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  363. /// <returns></returns>
  364. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgDistWeek", true)]
  365. public static AnalysisResultJson<UpStreamMsgDistWeekItem> GetUpStreamMsgDistWeek(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  366. {
  367. return ApiHandlerWapper.TryCommonApi(accessToken =>
  368. {
  369. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsgdistweek?access_token={0}";
  370. var data = new
  371. {
  372. begin_date = beginDate,
  373. end_date = endDate
  374. };
  375. return CommonJsonSend.Send<AnalysisResultJson<UpStreamMsgDistWeekItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  376. }, accessTokenOrAppId);
  377. }
  378. /// <summary>
  379. /// 获取消息发送分布月数据(getupstreammsgdistmonth)
  380. /// 最大时间跨度 30
  381. /// </summary>
  382. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  383. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  384. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  385. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  386. /// <returns></returns>
  387. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgDistMonth", true)]
  388. public static AnalysisResultJson<UpStreamMsgDistMonthItem> GetUpStreamMsgDistMonth(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  389. {
  390. return ApiHandlerWapper.TryCommonApi(accessToken =>
  391. {
  392. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsgdistmonth?access_token={0}";
  393. var data = new
  394. {
  395. begin_date = beginDate,
  396. end_date = endDate
  397. };
  398. return CommonJsonSend.Send<AnalysisResultJson<UpStreamMsgDistMonthItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  399. }, accessTokenOrAppId);
  400. }
  401. #endregion
  402. #region 用户分析数据接口
  403. /// <summary>
  404. /// 获取用户增减数据
  405. /// 最大时间跨度 7
  406. /// </summary>
  407. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  408. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  409. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  410. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  411. /// <returns></returns>
  412. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserSummary", true)]
  413. public static AnalysisResultJson<UserSummaryItem> GetUserSummary(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  414. {
  415. return ApiHandlerWapper.TryCommonApi(accessToken =>
  416. {
  417. string urlFormat = Config.ApiMpHost + "/datacube/getusersummary?access_token={0}";
  418. var data = new
  419. {
  420. begin_date = beginDate,
  421. end_date = endDate
  422. };
  423. return CommonJsonSend.Send<AnalysisResultJson<UserSummaryItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  424. }, accessTokenOrAppId);
  425. }
  426. /// <summary>
  427. /// 获取累计用户数据
  428. /// 最大时间跨度 7
  429. /// </summary>
  430. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  431. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  432. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  433. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  434. /// <returns></returns>
  435. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserCumulate", true)]
  436. public static AnalysisResultJson<UserCumulateItem> GetUserCumulate(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  437. {
  438. return ApiHandlerWapper.TryCommonApi(accessToken =>
  439. {
  440. string urlFormat = Config.ApiMpHost + "/datacube/getusercumulate?access_token={0}";
  441. var data = new
  442. {
  443. begin_date = beginDate,
  444. end_date = endDate
  445. };
  446. return CommonJsonSend.Send<AnalysisResultJson<UserCumulateItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  447. }, accessTokenOrAppId);
  448. }
  449. #endregion
  450. #endregion
  451. #if !NET35 && !NET40
  452. #region 异步方法
  453. #region 图文分析数据接口
  454. /// <summary>
  455. /// 【异步方法】获取图文群发每日数据(getarticlesummary)
  456. /// 最大时间跨度 1
  457. /// </summary>
  458. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  459. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  460. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  461. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  462. /// <returns></returns>
  463. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetArticleSummaryAsync", true)]
  464. public static async Task<AnalysisResultJson<ArticleSummaryItem>> GetArticleSummaryAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  465. {
  466. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  467. {
  468. string urlFormat = Config.ApiMpHost + "/datacube/getarticlesummary?access_token={0}";
  469. var data = new
  470. {
  471. begin_date = beginDate,
  472. end_date = endDate
  473. };
  474. return await
  475. Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<ArticleSummaryItem>>(
  476. accessToken, urlFormat, data,
  477. timeOut: timeOut);
  478. }, accessTokenOrAppId);
  479. }
  480. /// <summary>
  481. /// 【异步方法】获取图文群发总数据(getarticletotal)
  482. /// 请注意,details中,每天对应的数值为该文章到该日为止的总量(而不是当日的量)
  483. /// 最大时间跨度 1
  484. /// </summary>
  485. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  486. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  487. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  488. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  489. /// <returns></returns>
  490. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetArticleTotalAsync", true)]
  491. public static async Task<AnalysisResultJson<ArticleTotalItem>> GetArticleTotalAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  492. {
  493. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  494. {
  495. string urlFormat = Config.ApiMpHost + "/datacube/getarticletotal?access_token={0}";
  496. var data = new
  497. {
  498. begin_date = beginDate,
  499. end_date = endDate
  500. };
  501. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<ArticleTotalItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  502. }, accessTokenOrAppId);
  503. }
  504. /// <summary>
  505. /// 【异步方法】获取图文统计数据(getuserread)
  506. /// 最大时间跨度 3
  507. /// </summary>
  508. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  509. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  510. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  511. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  512. /// <returns></returns>
  513. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserReadAsync", true)]
  514. public static async Task<AnalysisResultJson<UserReadItem>> GetUserReadAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  515. {
  516. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  517. {
  518. string urlFormat = Config.ApiMpHost + "/datacube/getuserread?access_token={0}";
  519. var data = new
  520. {
  521. begin_date = beginDate,
  522. end_date = endDate
  523. };
  524. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UserReadItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  525. }, accessTokenOrAppId);
  526. }
  527. /// <summary>
  528. ///【异步方法】 获取图文统计分时数据(getuserreadhour)
  529. /// 最大时间跨度 1
  530. /// </summary>
  531. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  532. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  533. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  534. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  535. /// <returns></returns>
  536. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserReadHourAsync", true)]
  537. public static async Task<AnalysisResultJson<UserReadHourItem>> GetUserReadHourAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  538. {
  539. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  540. {
  541. string urlFormat = Config.ApiMpHost + "/datacube/getuserreadhour?access_token={0}";
  542. var data = new
  543. {
  544. begin_date = beginDate,
  545. end_date = endDate
  546. };
  547. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UserReadHourItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  548. }, accessTokenOrAppId);
  549. }
  550. /// <summary>
  551. /// 【异步方法】获取图文分享转发数据(getusershare)
  552. /// 最大时间跨度 7
  553. /// </summary>
  554. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  555. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  556. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  557. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  558. /// <returns></returns>
  559. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserShareAsync", true)]
  560. public static async Task<AnalysisResultJson<UserShareItem>> GetUserShareAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  561. {
  562. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  563. {
  564. string urlFormat = Config.ApiMpHost + "/datacube/getusershare?access_token={0}";
  565. var data = new
  566. {
  567. begin_date = beginDate,
  568. end_date = endDate
  569. };
  570. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UserShareItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  571. }, accessTokenOrAppId);
  572. }
  573. /// <summary>
  574. /// 【异步方法】获取图文分享转发分时数据(getusersharehour)
  575. /// 最大时间跨度 1
  576. /// </summary>
  577. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  578. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  579. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  580. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  581. /// <returns></returns>
  582. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserShareHourAsync", true)]
  583. public static async Task<AnalysisResultJson<UserShareHourItem>> GetUserShareHourAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  584. {
  585. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  586. {
  587. string urlFormat = Config.ApiMpHost + "/datacube/getusersharehour?access_token={0}";
  588. var data = new
  589. {
  590. begin_date = beginDate,
  591. end_date = endDate
  592. };
  593. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UserShareHourItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  594. }, accessTokenOrAppId);
  595. }
  596. #endregion
  597. #region 接口分析数据接口
  598. /// <summary>
  599. /// 【异步方法】获取接口分析数据(getinterfacesummary)
  600. /// 最大时间跨度 30
  601. /// </summary>
  602. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  603. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  604. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  605. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  606. /// <returns></returns>
  607. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetInterfaceSummaryAsync", true)]
  608. public static async Task<AnalysisResultJson<InterfaceSummaryItem>> GetInterfaceSummaryAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  609. {
  610. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  611. {
  612. string urlFormat = Config.ApiMpHost + "/datacube/getinterfacesummary?access_token={0}";
  613. var data = new
  614. {
  615. begin_date = beginDate,
  616. end_date = endDate
  617. };
  618. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<InterfaceSummaryItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  619. }, accessTokenOrAppId);
  620. }
  621. /// <summary>
  622. /// 【异步方法】获取接口分析分时数据(getinterfacesummaryhour)
  623. /// 最大时间跨度 1
  624. /// </summary>
  625. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  626. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  627. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  628. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  629. /// <returns></returns>
  630. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetInterfaceSummaryHourAsync", true)]
  631. public static async Task<AnalysisResultJson<InterfaceSummaryHourItem>> GetInterfaceSummaryHourAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  632. {
  633. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  634. {
  635. string urlFormat = Config.ApiMpHost + "/datacube/getinterfacesummaryhour?access_token={0}";
  636. var data = new
  637. {
  638. begin_date = beginDate,
  639. end_date = endDate
  640. };
  641. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<InterfaceSummaryHourItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  642. }, accessTokenOrAppId);
  643. }
  644. #endregion
  645. #region 消息分析数据接口
  646. /// <summary>
  647. /// 【异步方法】获取消息发送概况数据(getupstreammsg)
  648. /// 最大时间跨度 7
  649. /// </summary>
  650. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  651. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  652. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  653. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  654. /// <returns></returns>
  655. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgAsync", true)]
  656. public static async Task<AnalysisResultJson<UpStreamMsgItem>> GetUpStreamMsgAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  657. {
  658. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  659. {
  660. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsg?access_token={0}";
  661. var data = new
  662. {
  663. begin_date = beginDate,
  664. end_date = endDate
  665. };
  666. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UpStreamMsgItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  667. }, accessTokenOrAppId);
  668. }
  669. /// <summary>
  670. /// 【异步方法】获取消息分送分时数据(getupstreammsghour)
  671. /// 最大时间跨度 1
  672. /// </summary>
  673. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  674. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  675. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  676. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  677. /// <returns></returns>
  678. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgHourAsync", true)]
  679. public static async Task<AnalysisResultJson<UpStreamMsgHourItem>> GetUpStreamMsgHourAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  680. {
  681. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  682. {
  683. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsghour?access_token={0}";
  684. var data = new
  685. {
  686. begin_date = beginDate,
  687. end_date = endDate
  688. };
  689. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UpStreamMsgHourItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  690. }, accessTokenOrAppId);
  691. }
  692. /// <summary>
  693. /// 【异步方法】获取消息发送周数据(getupstreammsgweek)
  694. /// 最大时间跨度 30
  695. /// </summary>
  696. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  697. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  698. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  699. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  700. /// <returns></returns>
  701. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgWeekAsync", true)]
  702. public static async Task<AnalysisResultJson<UpStreamMsgWeekItem>> GetUpStreamMsgWeekAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  703. {
  704. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  705. {
  706. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsgweek?access_token={0}";
  707. var data = new
  708. {
  709. begin_date = beginDate,
  710. end_date = endDate
  711. };
  712. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UpStreamMsgWeekItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  713. }, accessTokenOrAppId);
  714. }
  715. /// <summary>
  716. /// 【异步方法】获取消息发送月数据(getupstreammsgmonth)
  717. /// 最大时间跨度 30
  718. /// </summary>
  719. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  720. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  721. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  722. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  723. /// <returns></returns>
  724. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgMonthAsync", true)]
  725. public static async Task<AnalysisResultJson<UpStreamMsgMonthItem>> GetUpStreamMsgMonthAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  726. {
  727. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  728. {
  729. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsgmonth?access_token={0}";
  730. var data = new
  731. {
  732. begin_date = beginDate,
  733. end_date = endDate
  734. };
  735. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UpStreamMsgMonthItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  736. }, accessTokenOrAppId);
  737. }
  738. /// <summary>
  739. /// 【异步方法】获取消息发送分布数据(getupstreammsgdist)
  740. /// 最大时间跨度 15
  741. /// </summary>
  742. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  743. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  744. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  745. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  746. /// <returns></returns>
  747. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgDistAsync", true)]
  748. public static async Task<AnalysisResultJson<UpStreamMsgDistItem>> GetUpStreamMsgDistAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  749. {
  750. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  751. {
  752. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsgdist?access_token={0}";
  753. var data = new
  754. {
  755. begin_date = beginDate,
  756. end_date = endDate
  757. };
  758. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UpStreamMsgDistItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  759. }, accessTokenOrAppId);
  760. }
  761. /// <summary>
  762. /// 【异步方法】获取消息发送分布周数据(getupstreammsgdistweek)
  763. /// 最大时间跨度 30
  764. /// </summary>
  765. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  766. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  767. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  768. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  769. /// <returns></returns>
  770. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgDistWeekAsync", true)]
  771. public static async Task<AnalysisResultJson<UpStreamMsgDistWeekItem>> GetUpStreamMsgDistWeekAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  772. {
  773. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  774. {
  775. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsgdistweek?access_token={0}";
  776. var data = new
  777. {
  778. begin_date = beginDate,
  779. end_date = endDate
  780. };
  781. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UpStreamMsgDistWeekItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  782. }, accessTokenOrAppId);
  783. }
  784. /// <summary>
  785. /// 【异步方法】获取消息发送分布月数据(getupstreammsgdistmonth)
  786. /// 最大时间跨度 30
  787. /// </summary>
  788. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  789. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  790. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  791. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  792. /// <returns></returns>
  793. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUpStreamMsgDistMonthAsync", true)]
  794. public static async Task<AnalysisResultJson<UpStreamMsgDistMonthItem>> GetUpStreamMsgDistMonthAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  795. {
  796. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  797. {
  798. string urlFormat = Config.ApiMpHost + "/datacube/getupstreammsgdistmonth?access_token={0}";
  799. var data = new
  800. {
  801. begin_date = beginDate,
  802. end_date = endDate
  803. };
  804. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UpStreamMsgDistMonthItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  805. }, accessTokenOrAppId);
  806. }
  807. #endregion
  808. #region 用户分析数据接口
  809. /// <summary>
  810. ///【异步方法】 获取用户增减数据
  811. /// 最大时间跨度 7
  812. /// </summary>
  813. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  814. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  815. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  816. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  817. /// <returns></returns>
  818. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserSummaryAsync", true)]
  819. public static async Task<AnalysisResultJson<UserSummaryItem>> GetUserSummaryAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  820. {
  821. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  822. {
  823. string urlFormat = Config.ApiMpHost + "/datacube/getusersummary?access_token={0}";
  824. var data = new
  825. {
  826. begin_date = beginDate,
  827. end_date = endDate
  828. };
  829. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UserSummaryItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  830. }, accessTokenOrAppId);
  831. }
  832. /// <summary>
  833. /// 【异步方法】获取累计用户数据
  834. /// 最大时间跨度 7
  835. /// </summary>
  836. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  837. /// <param name="beginDate">获取数据的起始日期,begin_date和end_date的差值需小于“最大时间跨度”(比如最大时间跨度为1时,begin_date和end_date的差值只能为0,才能小于1),否则会报错</param>
  838. /// <param name="endDate">获取数据的结束日期,end_date允许设置的最大值为昨日</param>
  839. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  840. /// <returns></returns>
  841. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "AnalysisApi.GetUserCumulateAsync", true)]
  842. public static async Task<AnalysisResultJson<UserCumulateItem>> GetUserCumulateAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
  843. {
  844. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  845. {
  846. string urlFormat = Config.ApiMpHost + "/datacube/getusercumulate?access_token={0}";
  847. var data = new
  848. {
  849. begin_date = beginDate,
  850. end_date = endDate
  851. };
  852. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AnalysisResultJson<UserCumulateItem>>(accessToken, urlFormat, data, timeOut: timeOut);
  853. }, accessTokenOrAppId);
  854. }
  855. #endregion
  856. #endregion
  857. #endif
  858. }
  859. }