golang,百度统计如何获得pv,uv等数据

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/fwhezfwhez/article/details/82685163

百度统计的接口文档给的非常简陋,这里不贴了,找到这个博客的人应该手里已经捏了一份接口文档,但是接不通。
从接口文档上的要求来看,似乎仅仅需要传:
【site_id,method,start_date,end_date,metrics,max_results,gran】
并且你以为传递的东西长这样:

{
        "site_id":xxxxxx,
        "method":"source/all/a",
        "start_date":"20180826",
        "end_date":"20180826",
        "metrics":"pv_count,pv_ratio,visit_count,visitor_count,ip_count",
        "max_results":0,
        "gran":"day"
}

但真正有效的,却又没有被写进文档的样例,是长这样:

{
    "header":{
        "account_type":1,
        "username":"xxx",
        "password":"xxxxx",
        "token":"xxxxxxxxxxxxxxxxx"
    },
    "body":{
        "site_id":xxx,
        "method":"source/all/a",
        "methodxxxxxxxxx":"visit/toppage/a",
        "start_date":"20180826",
        "end_date":"20180826",
        "metrics":"pv_count,pv_ratio,visit_count,visitor_count,ip_count",
        "max_results":0,
        "gran":"day"
    }

}

By the way,请求的method是POST,格式是 application/json
下面是讲讲多余的没写进的数据是怎么获取到的:
account_type 是账户类型
username和password是你在百度统计登录的账户密码
token在后台的管理-导出服务里可以看到
详情见这里:https://github.com/fwhezfwhez/baidutongji/blob/master/zhun-bei.md
也可以使用gitbook直接观看书籍
git clone https://github.com/fwhezfwhez/baidutongji.git
然后使用gitbook-editor打开。

猜你喜欢

转载自blog.csdn.net/fwhezfwhez/article/details/82685163