1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the overtrue/wechat. |
5
|
|
|
* |
6
|
|
|
* (c) overtrue <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Stats.php. |
14
|
|
|
* |
15
|
|
|
* Part of Overtrue\WeChat. |
16
|
|
|
* |
17
|
|
|
* For the full copyright and license information, please view the LICENSE |
18
|
|
|
* file that was distributed with this source code. |
19
|
|
|
* |
20
|
|
|
* @author mingyoung <[email protected]> |
21
|
|
|
* @copyright 2017 |
22
|
|
|
* |
23
|
|
|
* @see https://github.com/overtrue |
24
|
|
|
* @see http://overtrue.me |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
namespace EasyWeChat\MiniProgram\Stats; |
28
|
|
|
|
29
|
|
|
use EasyWeChat\MiniProgram\Core\AbstractMiniProgram; |
30
|
|
|
|
31
|
|
|
class Stats extends AbstractMiniProgram |
32
|
|
|
{ |
33
|
|
|
const SUMMARY_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailysummarytrend'; |
34
|
|
|
const DAILY_VISIT_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend'; |
35
|
|
|
const WEEKLY_VISIT_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyvisittrend'; |
36
|
|
|
const MONTHLY_VISIT_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyvisittrend'; |
37
|
|
|
const VISIT_DISTRIBUTION = 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitdistribution'; |
38
|
|
|
const DAILY_RETAIN_INFO = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailyretaininfo'; |
39
|
|
|
const WEEKLY_RETAIN_INFO = 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyretaininfo'; |
40
|
|
|
const MONTHLY_RETAIN_INFO = 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyretaininfo'; |
41
|
|
|
const VISIT_PAGE = 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitpage'; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Get summary trend. |
45
|
|
|
* |
46
|
|
|
* @param string $from |
47
|
|
|
* @param string $to |
48
|
|
|
* |
49
|
|
|
* @return \EasyWeChat\Support\Collection |
50
|
|
|
*/ |
51
|
1 |
|
public function summaryTrend($from, $to) |
52
|
|
|
{ |
53
|
1 |
|
return $this->query(self::SUMMARY_TREND, $from, $to); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get daily visit trend. |
58
|
|
|
* |
59
|
|
|
* @param string $from |
60
|
|
|
* @param string $to |
61
|
|
|
* |
62
|
|
|
* @return \EasyWeChat\Support\Collection |
63
|
|
|
*/ |
64
|
1 |
|
public function dailyVisitTrend($from, $to) |
65
|
|
|
{ |
66
|
1 |
|
return $this->query(self::DAILY_VISIT_TREND, $from, $to); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get weekly visit trend. |
71
|
|
|
* |
72
|
|
|
* @param string $from |
73
|
|
|
* @param string $to |
74
|
|
|
* |
75
|
|
|
* @return \EasyWeChat\Support\Collection |
76
|
|
|
*/ |
77
|
1 |
|
public function weeklyVisitTrend($from, $to) |
78
|
|
|
{ |
79
|
1 |
|
return $this->query(self::WEEKLY_VISIT_TREND, $from, $to); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Get monthly visit trend. |
84
|
|
|
* |
85
|
|
|
* @param string $from |
86
|
|
|
* @param string $to |
87
|
|
|
* |
88
|
|
|
* @return \EasyWeChat\Support\Collection |
89
|
|
|
*/ |
90
|
1 |
|
public function monthlyVisitTrend($from, $to) |
91
|
|
|
{ |
92
|
1 |
|
return $this->query(self::MONTHLY_VISIT_TREND, $from, $to); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Get visit distribution. |
97
|
|
|
* |
98
|
|
|
* @param string $from |
99
|
|
|
* @param string $to |
100
|
|
|
* |
101
|
|
|
* @return \EasyWeChat\Support\Collection |
102
|
|
|
*/ |
103
|
1 |
|
public function visitDistribution($from, $to) |
104
|
|
|
{ |
105
|
1 |
|
return $this->query(self::VISIT_DISTRIBUTION, $from, $to); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Get daily retain info. |
110
|
|
|
* |
111
|
|
|
* @param string $from |
112
|
|
|
* @param string $to |
113
|
|
|
* |
114
|
|
|
* @return \EasyWeChat\Support\Collection |
115
|
|
|
*/ |
116
|
1 |
|
public function dailyRetainInfo($from, $to) |
117
|
|
|
{ |
118
|
1 |
|
return $this->query(self::DAILY_RETAIN_INFO, $from, $to); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Get weekly retain info. |
123
|
|
|
* |
124
|
|
|
* @param string $from |
125
|
|
|
* @param string $to |
126
|
|
|
* |
127
|
|
|
* @return \EasyWeChat\Support\Collection |
128
|
|
|
*/ |
129
|
1 |
|
public function weeklyRetainInfo($from, $to) |
130
|
|
|
{ |
131
|
1 |
|
return $this->query(self::WEEKLY_RETAIN_INFO, $from, $to); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Get monthly retain info. |
136
|
|
|
* |
137
|
|
|
* @param string $from |
138
|
|
|
* @param string $to |
139
|
|
|
* |
140
|
|
|
* @return \EasyWeChat\Support\Collection |
141
|
|
|
*/ |
142
|
1 |
|
public function montylyRetainInfo($from, $to) |
143
|
|
|
{ |
144
|
1 |
|
return $this->query(self::MONTHLY_RETAIN_INFO, $from, $to); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Get visit page. |
149
|
|
|
* |
150
|
|
|
* @param string $from |
151
|
|
|
* @param string $to |
152
|
|
|
* |
153
|
|
|
* @return \EasyWeChat\Support\Collection |
154
|
|
|
*/ |
155
|
1 |
|
public function visitPage($from, $to) |
156
|
|
|
{ |
157
|
1 |
|
return $this->query(self::VISIT_PAGE, $from, $to); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Unify query. |
162
|
|
|
* |
163
|
|
|
* @param string $from |
164
|
|
|
* @param string $to |
165
|
|
|
* |
166
|
|
|
* @return \EasyWeChat\Support\Collection |
167
|
|
|
*/ |
168
|
9 |
|
protected function query($api, $from, $to) |
169
|
|
|
{ |
170
|
|
|
$params = [ |
171
|
9 |
|
'begin_date' => $from, |
172
|
9 |
|
'end_date' => $to, |
173
|
9 |
|
]; |
174
|
|
|
|
175
|
9 |
|
return $this->parseJSON('json', [$api, $params]); |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
|