怎么通过百度 API 获得分小时报告

Power Query 未煮成茶 ⋅ 于 2019-05-22 14:50:07 ⋅ 最后回复由 初出茅庐 2019-09-19 10:59:55 ⋅ 2364 阅读

通过雷公子的文章
https://pbihub.cn/blog/47
实现了在BI中获取分日的计划报告,想实现分小时的计划报告,请问各位大佬应该如何修改代码

回复数量: 1
  • 初出茅庐
    2019-09-19 10:59:55

    let
    fn = (账户,密码,秘钥,开始日期 as date ,结束日期 as date) =>

    let
    zd = 0,
    url="https://api.baidu.com/json/sms/service/ReportService/getRealTimeData",
    content="{
    ""header"":{
    ""username"":"""&账户&""",
    ""password"":"""&密码&""",
    ""token"":"""&秘钥&"""
    },
    ""body"":{
    ""realTimeRequestType"":{
    ""performanceData"":[
    ""impression"",
    ""click"",
    ""cost"",
    ""cpc"",
    ""ctr""
    ],
    ""levelOfDetails"":3,
    ""reportType"":5,
    ""startDate"":"""&Date.ToText(开始日期,"yyyy-MM-dd")&""",
    ""endDate"":"""&Date.ToText(结束日期,"yyyy-MM-dd")&""",
    ""device"":"""&Number.ToText(zd)&""",
    ""untilOfTime"":5
    }
    }
    }",
    request=Json.Document(Web.Contents(url,[Content=Text.ToBinary(content)])),
    data = Table.FromRecords(request[body][data]),
    title = {{"展现","点击","消费","平均点击价格","点击率"},{"账户","计划","省","市"}},
    kpi = Table.TransformColumns(request[body][data],{"kpis",each Record.FromList(,title{0})}),
    name = Table.TransformColumns(kpi,{"name",each Record.FromList(
    ,title{1})}),
    expand_kpi = Table.ExpandRecordColumn(name, "kpis", title{0}),
    expand_name = Table.ExpandRecordColumn(expand_kpi, "name", title{1}),
    delete = Table.RemoveColumns(expand_name,{"平均点击价格", "点击率"}),
    types = Table.TransformColumnTypes(delete,{{"展现", Int64.Type}, {"点击", Int64.Type}, {"消费", type number}, {"计划", type text},{"date", type date}})
    in
    request[body][data]
    in fn

暂无评论~~
  • 请务必阅读并严格遵守《社区管理规范与使用说明》
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`, 更多语法请见这里 Markdown 语法
  • 支持表情,使用方法请见 发送表情,可用的 Emoji 见 :metal: :point_right: Emoji 列表 :star: :sparkles:
  • 上传图片, 支持拖拽和剪切板粘贴上传, 格式限制 - jpg, png, gif
  • 不支持上传附件,请尽可能用文字和图片将问题描述清楚,如实在需要上传附件,可上传到 共享网盘 后分享链接
  • 发布框支持本地存储功能,会在内容变更时保存,「提交」按钮点击时清空
  请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
Ctrl+Enter