melodic/baidu-tongji

There is no license information available for the latest version (1.0) of this package.

1.0 2017-07-18 05:37 UTC

This package is not auto-updated.

Last update: 2025-08-17 07:38:55 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);
    }
}