我尝试了Google提供的API,但我从未获得以下数据加入字段。
https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token= {}的access_token
{
id: "xxx12212121",
email: "xxx@gmail.com",
verified_email: true,
name: "name",
given_name: "given",
family_name: "family",
link: "",
picture: "",
gender: "male",
locale: "en"
}
我从中获取用户信息。
https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&access_token= {}的access_token
{
kind: "youtube#channelListResponse",
etag: ""m2yskBQFythfE4irbTIeOgYYfBU/z1gqFgh3CSk3IPqbcioKrdSLWC8"",
pageInfo: {
totalResults: 1,
resultsPerPage: 1
},
items: [
{
kind: "youtube#channel",
etag: ""m2yskBQFythfE4irbTIeOgYYfBU/ZhbI7F3l_8IFIKdqr4bM1ypv-vI"",
id: "UCaWN2zhl0zuSdZWW11WcYGg"
}
]
}
我从中获得了频道ID。
我应该包含哪些内容才能确定YouTube用户开始或加入的日期?
答案 0 :(得分:0)
YouTube API中的信息以所谓的部分组织。在您的示例中,您请求了频道资源的id
部分。您寻求的属性包含在snippet
部分中,称为publishedAt
。
因此,您的网址应如下所示:
https://www.googleapis.com/youtube/v3/channels?part=id,snippet&mine=true&access_token=ACCESS_TOKEN
请注意,您可以通过逗号分隔来请求多个部分。这将得到以下结果:
{
"kind": "youtube#channelListResponse",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/bFgk_cna5xETz2qMNX9ggxvvny8\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/TlIL_94eU05dqfDk52YIjQnlu6c\"",
"id": "UCaWN2zhl0zuSdZWW11WcYGg",
"snippet": {
"title": "Oliver Susano",
"description": "",
"publishedAt": "2006-07-04T07:42:01.000Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/-K24hhru6jNo/AAAAAAAAAAI/AAAAAAAAAAA/Z9DpkE9NMqM/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
},
"medium": {
"url": "https://yt3.ggpht.com/-K24hhru6jNo/AAAAAAAAAAI/AAAAAAAAAAA/Z9DpkE9NMqM/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
},
"high": {
"url": "https://yt3.ggpht.com/-K24hhru6jNo/AAAAAAAAAAI/AAAAAAAAAAA/Z9DpkE9NMqM/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
}
},
"localized": {
"title": "Oliver Susano",
"description": ""
}
}
}
]
}