简体   繁体   English

使用 slack API 获取对话列表

[英]Using slack API to get conversation lists

I am trying to invoke following slack API to fetch private and public channels.我正在尝试调用以下 slack API 来获取私人和公共频道。 https://api.slack.com/methods/conversations.list https://api.slack.com/methods/conversations.list

By default as per slack documentation 200 channels are returned at a time when limit is given 1000.默认情况下,根据 slack 文档,当 limit 为 1000 时,一次返回 200 个通道。

I am passing types= “private_channel,public_channel“ to get the private as well as public channels.我正在传递 types= “private_channel,public_channel“ 以获取私人和公共频道。

  1. If I pass the types = public_channel with limit 1000 or 9999,如果我通过限制为 1000 或 9999 的 types = public_channel,
  • 162 channels are returned返回 162 个通道
  1. If I pass the types= private_channel,public_channel with limit 1000 or 9999,如果我通过 types= private_channel,public_channel 限制为 1000 或 9999,
  • 105 channels are returned返回 105 个通道

Can anybody please answer same.任何人都可以回答同样的问题吗?

With the way pagination works in that API, it's possible to get fewer than the number of results you're asking for, even if there are more results in the total collection to return.通过分页在 API 中的工作方式,即使要返回的总集合中有更多结果,也可能获得少于您要求的结果数。 You'll need to check if there are additional pages of results and crawl through all of them to build the complete set.您需要检查是否有其他页面的结果并爬过所有页面以构建完整的结果集。

This is because of the way data is retrieved in the back end -- it includes archived data, data of other types -- all the filtering that happens for your result happens after the data is fetched, making additional API calls required to get the next window of data to be filtered and then presented to you.这是因为在后端检索数据的方式——它包括归档数据、其他类型的数据——对结果进行的所有过滤都发生在数据被提取之后,需要额外的 API 调用才能获得下一个window 的数据被过滤然后呈现给你。

Here's the relevant documentation :这是相关文件

It's possible to receive fewer results than your specified limit, even when there are additional results to retrieve.接收到的结果可能少于您指定的限制,即使有额外的结果要检索也是如此。 Avoid the temptation to check the size of results against the limit to conclude the results have been completely returned.避免根据限制检查结果大小以得出结果已完全返回的结论。 Instead, check the next_cursor value in the response_metadata object to make sure that it's empty, null, or non-existent.相反,检查 response_metadata object 中的 next_cursor 值以确保它为空、null 或不存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM