如何通过排序检索最后订阅者,例如在 youtube 中?

How to retrieve last subscribers with sorting such as in youtube?

我用的是简单的方法,比如我们

buildApiRequest('GET','/youtube/v3/channels',
{
  'mySubscribers': true,
  'maxResults': MaxResult,
  'part': 'snippet'
}

有效,但结果我看不出如何对它们进行排序。 我需要最后的 MaxResult 订阅者,我想按频道上的加入日期对他们进行排序。

myRecentSubscribers 设置为 true 的 subscriptions.list 和 subscriberSnippet return 是您频道的重发订阅者列表。它不 return 所有这些。

如果您查看回复,您会发现没有日期。您将无法看到有人订阅的时间。

"subscriberSnippet": {
    "title": string,
    "description": string,
    "channelId": string,
    "thumbnails": {
      (key): {
        "url": string,0
        "width": unsigned integer,
        "height": unsigned integer
      }
    }

顺序参数应该允许您按标题排序,您不能更改它用于排序的参数。

buildApiRequest('GET',
            '/youtube/v3/subscriptions',
            {'part': 'subscriberSnippet',
             'myRecentSubscribers': 'true',
              'order', 'alphabetical'});

回应

{
 "kind": "youtube#subscriptionListResponse",
 "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/wLsZnuAVb0T9-bdRdCnreaWBHNM\"",
 "nextPageToken": "CAUQAA",
 "pageInfo": {
  "totalResults": 7,
  "resultsPerPage": 5
 },
 "items": [
  {

  "kind": "youtube#subscription",
   "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/3_huGriwUWV4fbbzcclmEoNYJ3w\"",
   "id": "moP_YQe1scKJgrI0udrz3B2tJTmRwvz4ev3R2_L4JmI",
   "subscriberSnippet": {
    "title": "Kortney W",
    "description": "",
    "channelId": "UC33FFHTxOZ6NRZAp9afsRBw",
    "thumbnails": {
     "default": {
      "url": "https://yt3.ggpht.com/-T6Sn1ur07bk/AAAAAAAAAAI/AAAAAAAAAAA/BSSSRckoD4k/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
     },
     "medium": {
      "url": "https://yt3.ggpht.com/-T6Sn1ur07bk/AAAAAAAAAAI/AAAAAAAAAAA/BSSSRckoD4k/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
     },
     "high": {
      "url": "https://yt3.ggpht.com/-T6Sn1ur07bk/AAAAAAAAAAI/AAAAAAAAAAA/BSSSRckoD4k/s800-c-k-no-mo-rj-c0xffffff/photo.jpg"
     }
    }
   }
  },
  {


   "kind": "youtube#subscription",
   "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/UVJds9Q4d24quS-sEG8Qw_3MBzU\"",
   "id": "gI5QI3teCs8unbR7__8oVg7KlRfOtWQYR70kXNkS4PY",
   "subscriberSnippet": {
    "title": "TheCorty",
    "description": "",
    "channelId": "UC-0O3PZ0VPNySP2bNFAPDIA",
    "thumbnails": {
     "default": {
      "url": "https://yt3.ggpht.com/-8C6KXmEqDho/AAAAAAAAAAI/AAAAAAAAAAA/1roVNa2yF0o/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
     },
     "medium": {
      "url": "https://yt3.ggpht.com/-8C6KXmEqDho/AAAAAAAAAAI/AAAAAAAAAAA/1roVNa2yF0o/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
     },
     "high": {
      "url": "https://yt3.ggpht.com/-8C6KXmEqDho/AAAAAAAAAAI/AAAAAAAAAAA/1roVNa2yF0o/s800-c-k-no-mo-rj-c0xffffff/photo.jpg"
     }
    }
   }
  }
 ]
}
  1. 这只有在您拥有该频道时才有效
  2. 它不会 return 您所有的订阅者都是最新的。
  3. 回复中没有日期,您无法按日期排序。
  4. 你可以测试这个here只要确保你验证到正确的频道