因此,我正在尝试使用货币分析 API 来获取给定 YouTube 频道的收益报告。 https://developers.google.com/youtube/analytics/v1/content_owner_reports
但是,要使用此 API,需要满足以下条件:
要检索内容所有者报告,请将 API 请求中的 ids 参数值设置为 contentOwner==OWNER_NAME,其中 OWNER_NAME 指定内容所有者的 ID。如果您不确定价值,请询问您的合作伙伴经理。
所以,在网上浏览之后,我发现了非官方的文档,这可能就是我要找的。 http://jump.techden.in/developers.google.com/youtube/partner/docs/v1/contentOwners/list
所以我添加了https://www.googleapis.com/auth/youtubepartner
范围,重新认证,并提出了这个请求:
def list_content_owners
conn = FaradayAdapter.new("https://www.googleapis.com").conn
params = {
:fetchMine => true,
:key => DEVELOPER_KEY
}
resp = conn.get do |req|
req.url "/youtube/partner/v1/contentOwners", params
req.headers["Authorization"] = "Bearer #{@token}"
end
debugger
return nil unless resp.try(:status) == 200
JSON.parse resp.body || nil
end
但是,我收到以下 403 错误:
(rdb:1) resp.body "{\n \"error\": {\n \"errors\": [\n {\n
\"domain\": \"usageLimits\",\n \"reason \": \"accessNotConfigured\",\n \"message\": \"访问未配置\"\n }\n ],\n \"code\": 403,\n \"message\": \ "未配置访问权限\"\n }\n}\n"
我查看了我的开发者控制台https://code.google.com/apis/console/并且我已经启用了所有与 YouTube 相关的 API。没有可用的特殊合作伙伴 API 列表。
那么,如果我无法获得contentOwner id
,Analytics API 的意义何在?