melodic/baidu-tongji

此包最新版本(1.0)没有可用的许可信息。

1.0 2017-07-18 05:37 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:49:44 UTC


README

感谢 https://github.com/mushan0703/BaiduTongji

主要参考了这个项目并进行了一些小的调整

请参考百度统计文档进行使用,本项目可以与tp5 + 一起使用

安装

  1. 安装包文件
composer require melodic/baidu-tongji
<?php

namespace app\Index\Controllers;

use think\Controller;
use Melodic\Tongji\BaiduTongji;

class Index extends Controller
{

    public function index()
    {
        $baiduTongji= new BaiduTongji();
        $today=date('Ymd');
        $yesterday=date('Ymd',strtotime('yesterday'));
        $result=$baiduTongji->getData([
            'method' => 'trend/time/a',
            'start_date' => $today,
            'end_date' => $today,
            'start_date2' => $yesterday,
            'end_date2' => $yesterday,
            'metrics' => 'pv_count,visitor_count',
            'max_results' => 0,
            'gran' => 'day',
        ]);
        return json($result);
    }
}