我想将LinkedIn Ads数据加载到我的Power BI报告中。
是否有任何简单的方法来访问数据?
谢谢!
答案 0 :(得分:0)
原来,您需要按照以下文档进行编写或自定义连接器:
https://docs.microsoft.com/en-us/power-query/samples/trippin/readme
或者您需要用M编写用于访问API的自定义代码:
let
GetAccessToken =
let
TokenEndpointUrl = #"TokenEndpoint" & "?client_id=" & #"AppID" & "&client_secret=" & #"AppSecret" & "&grant_type=client_credentials",
TokenRequestResult = Json.Document(Web.Contents(TokenEndpointUrl)),
AccessToken = TokenRequestResult[access_token]
in
AccessToken,
GetData = (Url) =>
let
FinalResult = if Url = ""
then
{}
else
let
Result = Json.Document(Web.Contents(Url,[
Query=[
date_preset="lifetime",
level="ad",
fields="impressions,spend,account_id,account_name,campaign_id,campaign_name,adset_id,adset_name,ad_id,ad_name",
time_increment="monthly"]
])),
NextUrl = Record.FieldOrDefault(Result[paging],"next",""),
CombinedData = Result[data] & @GetData(NextUrl)
in
CombinedData
in
FinalResult,
#"Data Endpoint" = #"DataEndpoint",
AccessToken = GetAccessToken,
#"Calls the functions and makes the result" = GetData(#"Data Endpoint" & "&acces_token=" & AccessToken)
in
#"Calls the functions and makes the result"
在此处发布答案也许对其他人也有帮助。