12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace wx\miniprogram;
- use ErrorException;
- use wx\Base;
- /**
- * 小程序数据分析
- *
- * @method json getVisitPage() static 获取用户访问小程序日留存
- * @method json getMonthlyRetain() static 获取用户访问小程序月留存
- * @method json getWeeklyRetain() static 获取用户访问小程序周留存
- * @method json getDailySummary() static 获取用户访问小程序数据概况
- * @method json getDailyVisitTrend() static 获取用户访问小程序数据日趋势
- * @method json getMonthlyVisitTrend() static 获取用户访问小程序数据月趋势(能查询到的最新数据为上一个自然月的数据)
- * @method json getWeeklyVisitTrend() static 获取用户访问小程序数据周趋势
- * @method json getPerformanceData() static 获取小程序启动性能,运行性能等数据。
- * @method json getUserPortrait() static 获取小程序新增或活跃用户的画像分布数据。时间范围支持昨天、最近7天、最近30天。其中,新增用户数为时间范围内首次访问小程序的去重用户数,活跃用户数为时间范围内访问过小程序的去重用户数。
- * @method json getVisitDistribution() static 获取用户小程序访问分布数据
- * @method json getVisitPage() static 访问页面。目前只提供按 page_visit_pv 排序的 top200。
- */
- class Analysis extends Base
- {
- private $requestUrl = [
- 'getVisitPage' => 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitpage?access_token=',
- 'getMonthlyRetain' => 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyretaininfo?access_token=',
- 'getWeeklyRetain' => 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyretaininfo?access_token=',
- 'getDailySummary' => 'https://api.weixin.qq.com/datacube/getweanalysisappiddailysummarytrend?access_token=',
- 'getDailyVisitTrend' => 'https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token=',
- 'getMonthlyVisitTrend' => 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyvisittrend?access_token=',
- 'getWeeklyVisitTrend' => 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyvisittrend?access_token=',
- 'getPerformanceData' => 'https://api.weixin.qq.com/wxa/business/performance/boot?access_token=',
- 'getUserPortrait' => 'https://api.weixin.qq.com/datacube/getweanalysisappiduserportrait?access_token=',
- 'getVisitDistribution' => 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitdistribution?access_token=',
- 'getVisitPage' => 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitpage?access_token=',
- ];
- public function __call($method, $arguments)
- {
- if (!isset($this->requestUrl[$method])) {
- throw new ErrorException('Method ' . $method . ' not exists');
- }
- $num = count($arguments);
- if ($num != 2) {
- throw new ErrorException('Method ' . $method . ' needs two arguments. ' . $num . ' arguments given.');
- }
- $url = $this->requestUrl[$method] . $arguments[0];
- $data = $this->curl($url, json_encode($arguments[1]));
- return $data;
- }
- }
|