Client::compare()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Freyo\MtaH5\User;
4
5
use Freyo\MtaH5\Kernel\BaseClient;
6
7
class Client extends BaseClient
8
{
9
    /**
10
     * 应用在24小时内的实时访客信息.
11
     *
12
     * @see https://mta.qq.com/docs/h5_api.html#%E5%AE%9E%E6%97%B6%E8%AE%BF%E5%AE%A2
13
     *
14
     * @param int $page 每页200条记录
15
     *
16
     * @throws \Freyo\MtaH5\Kernel\Exceptions\InvalidConfigException
17
     *
18
     * @return array|\Freyo\MtaH5\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
19
     */
20
    public function realtime($page = 1)
21
    {
22
        $params = [
23
            'page' => $page,
24
        ];
25
26
        return $this->httpGet('ctr_user_realtime', $params);
27
    }
28
29
    /**
30
     * 按天查询当天新访客与旧访客的数量.
31
     *
32
     * @see https://mta.qq.com/docs/h5_api.html#%E6%96%B0%E8%80%81%E8%AE%BF%E5%AE%A2%E6%AF%94
33
     *
34
     * @param string $startDate 开始时间(Y-m-d)
35
     * @param string $endDate   结束时间(Y-m-d)
36
     *
37
     * @throws \Freyo\MtaH5\Kernel\Exceptions\InvalidConfigException
38
     *
39
     * @return array|\Freyo\MtaH5\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
40
     */
41
    public function compare($startDate, $endDate)
42
    {
43
        $params = [
44
            'start_date' => $startDate,
45
            'end_date'   => $endDate,
46
        ];
47
48
        return $this->httpGet('ctr_user_compare', $params);
49
    }
50
51
    /**
52
     * 在H5统计平台查询用户画像数据,包含性别比例、年龄分布、学历分布、职业分布。接口的数据为pv量。
53
     *
54
     * @see https://mta.qq.com/docs/h5_api.html#%E7%94%A8%E6%88%B7%E7%94%BB%E5%83%8F
55
     *
56
     * @param string $startDate 开始时间(Y-m-d)
57
     * @param string $endDate   结束时间(Y-m-d)
58
     *
59
     * @throws \Freyo\MtaH5\Kernel\Exceptions\InvalidConfigException
60
     *
61
     * @return array|\Freyo\MtaH5\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
62
     */
63
    public function portrait($startDate, $endDate)
64
    {
65
        $params = [
66
            'start_date' => $startDate,
67
            'end_date'   => $endDate,
68
            'idx'        => 'sex,age,grade,profession',
69
        ];
70
71
        return $this->httpGet('ctr_user_portrait', $params);
72
    }
73
}
74