Total.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2023 ThinkAdmin [ thinkadmin.top ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免责声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
  13. // | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
  14. // +----------------------------------------------------------------------
  15. namespace WeMini;
  16. use WeChat\Contracts\BasicWeChat;
  17. /**
  18. * 微信小程序数据接口
  19. * Class Total
  20. * @package WeMini
  21. */
  22. class Total extends BasicWeChat
  23. {
  24. /**
  25. * 数据分析接口
  26. * @param string $begin_date 开始日期
  27. * @param string $end_date 结束日期,限定查询1天数据,end_date允许设置的最大值为昨日
  28. * @return array
  29. * @throws \WeChat\Exceptions\InvalidResponseException
  30. * @throws \WeChat\Exceptions\LocalCacheException
  31. */
  32. public function getWeanalysisAppidDailySummarytrend($begin_date, $end_date)
  33. {
  34. $url = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailysummarytrend?access_token=ACCESS_TOKEN';
  35. return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
  36. }
  37. /**
  38. * 访问分析
  39. * @param string $begin_date 开始日期
  40. * @param string $end_date 结束日期,限定查询1天数据,end_date允许设置的最大值为昨日
  41. * @return array
  42. * @throws \WeChat\Exceptions\InvalidResponseException
  43. * @throws \WeChat\Exceptions\LocalCacheException
  44. */
  45. public function getWeanalysisAppidDailyVisittrend($begin_date, $end_date)
  46. {
  47. $url = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token=ACCESS_TOKEN';
  48. return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
  49. }
  50. /**
  51. * 周趋势
  52. * @param string $begin_date 开始日期,为周一日期
  53. * @param string $end_date 结束日期,为周日日期,限定查询一周数据
  54. * @return array
  55. * @throws \WeChat\Exceptions\InvalidResponseException
  56. * @throws \WeChat\Exceptions\LocalCacheException
  57. */
  58. public function getWeanalysisAppidWeeklyVisittrend($begin_date, $end_date)
  59. {
  60. $url = 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyvisittrend?access_token=ACCESS_TOKEN';
  61. return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
  62. }
  63. /**
  64. * 月趋势
  65. * @param string $begin_date 开始日期,为自然月第一天
  66. * @param string $end_date 结束日期,为自然月最后一天,限定查询一个月数据
  67. * @return array
  68. * @throws \WeChat\Exceptions\InvalidResponseException
  69. * @throws \WeChat\Exceptions\LocalCacheException
  70. */
  71. public function getWeanalysisAppidMonthlyVisittrend($begin_date, $end_date)
  72. {
  73. $url = 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyvisittrend?access_token=ACCESS_TOKEN';
  74. return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
  75. }
  76. /**
  77. * 访问分布
  78. * @param string $begin_date 开始日期
  79. * @param string $end_date 结束日期,限定查询1天数据,end_date允许设置的最大值为昨日
  80. * @return array
  81. * @throws \WeChat\Exceptions\InvalidResponseException
  82. * @throws \WeChat\Exceptions\LocalCacheException
  83. */
  84. public function getWeanalysisAppidVisitdistribution($begin_date, $end_date)
  85. {
  86. $url = 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitdistribution?access_token=ACCESS_TOKEN';
  87. return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
  88. }
  89. /**
  90. * 日留存
  91. * @param string $begin_date 开始日期
  92. * @param string $end_date 结束日期,限定查询1天数据,end_date允许设置的最大值为昨日
  93. * @return array
  94. * @throws \WeChat\Exceptions\InvalidResponseException
  95. * @throws \WeChat\Exceptions\LocalCacheException
  96. */
  97. public function getWeanalysisAppidDailyRetaininfo($begin_date, $end_date)
  98. {
  99. $url = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailyretaininfo?access_token=ACCESS_TOKEN';
  100. return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
  101. }
  102. /**
  103. * 周留存
  104. * @param string $begin_date 开始日期,为周一日期
  105. * @param string $end_date 结束日期,为周日日期,限定查询一周数据
  106. * @return array
  107. * @throws \WeChat\Exceptions\InvalidResponseException
  108. * @throws \WeChat\Exceptions\LocalCacheException
  109. */
  110. public function getWeanalysisAppidWeeklyRetaininfo($begin_date, $end_date)
  111. {
  112. $url = 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyretaininfo?access_token=ACCESS_TOKEN';
  113. return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
  114. }
  115. /**
  116. * 月留存
  117. * @param string $begin_date 开始日期,为自然月第一天
  118. * @param string $end_date 结束日期,为自然月最后一天,限定查询一个月数据
  119. * @return array
  120. * @throws \WeChat\Exceptions\InvalidResponseException
  121. * @throws \WeChat\Exceptions\LocalCacheException
  122. */
  123. public function getWeanalysisAppidMonthlyRetaininfo($begin_date, $end_date)
  124. {
  125. $url = 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyretaininfo?access_token=ACCESS_TOKEN';
  126. return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
  127. }
  128. /**
  129. * 访问页面
  130. * @param string $begin_date 开始日期
  131. * @param string $end_date 结束日期,限定查询1天数据,end_date允许设置的最大值为昨日
  132. * @return array
  133. * @throws \WeChat\Exceptions\InvalidResponseException
  134. * @throws \WeChat\Exceptions\LocalCacheException
  135. */
  136. public function getWeanalysisAppidVisitPage($begin_date, $end_date)
  137. {
  138. $url = 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitpage?access_token=ACCESS_TOKEN';
  139. return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
  140. }
  141. /**
  142. * 用户画像
  143. * @param string $begin_date 开始日期
  144. * @param string $end_date 结束日期,开始日期与结束日期相差的天数限定为0/6/29,分别表示查询最近1/7/30天数据,end_date允许设置的最大值为昨日
  145. * @return array
  146. * @throws \WeChat\Exceptions\InvalidResponseException
  147. * @throws \WeChat\Exceptions\LocalCacheException
  148. */
  149. public function getWeanalysisAppidUserportrait($begin_date, $end_date)
  150. {
  151. $url = 'https://api.weixin.qq.com/datacube/getweanalysisappiduserportrait?access_token=ACCESS_TOKEN';
  152. return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
  153. }
  154. }