Total.php 7.2 KB

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