| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <?php
- /*
- * This file is part of the overtrue/wechat.
- *
- * (c) overtrue <i@overtrue.me>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- /**
- * Stats.php.
- *
- * Part of Overtrue\WeChat.
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @author mingyoung <mingyoungcheung@gmail.com>
- * @copyright 2017
- *
- * @see https://github.com/overtrue
- * @see http://overtrue.me
- */
- namespace EasyWeChat\MiniProgram\Stats;
- use EasyWeChat\MiniProgram\Core\AbstractMiniProgram;
- class Stats extends AbstractMiniProgram
- {
- const SUMMARY_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailysummarytrend';
- const DAILY_VISIT_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend';
- const WEEKLY_VISIT_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyvisittrend';
- const MONTHLY_VISIT_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyvisittrend';
- const VISIT_DISTRIBUTION = 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitdistribution';
- const DAILY_RETAIN_INFO = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailyretaininfo';
- const WEEKLY_RETAIN_INFO = 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyretaininfo';
- const MONTHLY_RETAIN_INFO = 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyretaininfo';
- const VISIT_PAGE = 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitpage';
- const USER_PORTRAIT = 'https://api.weixin.qq.com/datacube/getweanalysisappiduserportrait';
- /**
- * Get summary trend.
- *
- * @param string $from
- * @param string $to
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function summaryTrend($from, $to)
- {
- return $this->query(self::SUMMARY_TREND, $from, $to);
- }
- /**
- * Get daily visit trend.
- *
- * @param string $from
- * @param string $to
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function dailyVisitTrend($from, $to)
- {
- return $this->query(self::DAILY_VISIT_TREND, $from, $to);
- }
- /**
- * Get weekly visit trend.
- *
- * @param string $from
- * @param string $to
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function weeklyVisitTrend($from, $to)
- {
- return $this->query(self::WEEKLY_VISIT_TREND, $from, $to);
- }
- /**
- * Get monthly visit trend.
- *
- * @param string $from
- * @param string $to
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function monthlyVisitTrend($from, $to)
- {
- return $this->query(self::MONTHLY_VISIT_TREND, $from, $to);
- }
- /**
- * Get visit distribution.
- *
- * @param string $from
- * @param string $to
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function visitDistribution($from, $to)
- {
- return $this->query(self::VISIT_DISTRIBUTION, $from, $to);
- }
- /**
- * Get daily retain info.
- *
- * @param string $from
- * @param string $to
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function dailyRetainInfo($from, $to)
- {
- return $this->query(self::DAILY_RETAIN_INFO, $from, $to);
- }
- /**
- * Get weekly retain info.
- *
- * @param string $from
- * @param string $to
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function weeklyRetainInfo($from, $to)
- {
- return $this->query(self::WEEKLY_RETAIN_INFO, $from, $to);
- }
- /**
- * Get monthly retain info.
- *
- * @param string $from
- * @param string $to
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function montylyRetainInfo($from, $to)
- {
- return $this->query(self::MONTHLY_RETAIN_INFO, $from, $to);
- }
- /**
- * Get visit page.
- *
- * @param string $from
- * @param string $to
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function visitPage($from, $to)
- {
- return $this->query(self::VISIT_PAGE, $from, $to);
- }
- /**
- * Get user portrait.
- *
- * @param string $from
- * @param string $to
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function userPortrait($from, $to)
- {
- return $this->query(self::USER_PORTRAIT, $from, $to);
- }
- /**
- * Unify query.
- *
- * @param string $from
- * @param string $to
- *
- * @return \EasyWeChat\Support\Collection
- */
- protected function query($api, $from, $to)
- {
- $params = [
- 'begin_date' => $from,
- 'end_date' => $to,
- ];
- return $this->parseJSON('json', [$api, $params]);
- }
- }
|