问题描述
通过使用以下curl命令,我可以检索给定日期范围内所有答案的列表:
I am able to retrieve a list of all my answers, within a given date range, by using this below curl command:
curl "https://api.stackexchange.com/2.2/users/10348758/answers?page=1&pagesize=100&fromdate=1588291200&todate=1592179200&order=desc&sort=activity&site=stackoverflow&access_token=my-access-token&key=my-key" | gunzip
我需要找到给定日期范围内无法接受的答案的列表.
I need to find the list of my unaccepted answers within a given date range.
根据文档,可以将这些字段应用于答案类型.
According to the documentation, these fields can be applied to the answer type.
在文档中写道:
因此,我还创建了access_token
,范围为private_info
.
So, I have also created access_token
with the scope being private_info
.
我以以下方式修改了命令:
I have modified my command in the following way :
curl "https://api.stackexchange.com/2.2/users/10348758/answers?is_accepted=false?page=1&pagesize=100&fromdate=1588291200&todate=1592179200&order=desc&sort=activity&site=stackoverflow" | gunzip
在上面的命令中,我添加了is_accepted=false
参数,但是得到的结果与上面的命令相同,即我得到了完整的答案列表.我只想检索那些我的不可接受的答案(在给定的日期范围内).我是否需要在curl
命令中应用过滤器?
In the above command, I have added the is_accepted=false
parameter, but I am getting the same result as the above command i.e. I am getting a complete list of answers. I want to retrieve only those answers of mine which are unaccepted (within a given date range). Do I need to apply a filter in the curl
command?
如何使用Stack Exchange API检索我所有未接受的答案(在给定的日期范围内)的列表?
How can I retrieve a list of all my unaccepted answers (within a given date range) using Stack Exchange API?
推荐答案
is_accepted
是字段之一.而且,在当前阶段,这似乎不能用于过滤结果值作为查询参数.
is_accepted
is one of the fields. And, in the current stage, it seems that this cannot be used for filtering the result values as the query parameter.
在这种情况下,以下解决方法如何?我想建议使用jq
来过滤检索到的值.在这种解决方法中,使用jq
从所有检索到的值中检索具有is_accepted: false
的值.
From this situation, how about the following workaround? I would like to propose to use jq
for filtering the retrieved values. In this workaround, the values with is_accepted: false
are retrieved from the all retrieved values using jq
.
curl "https://api.stackexchange.com/2.2/users/10348758/answers?page=1&pagesize=100&fromdate=1588291200&todate=1592179200&order=desc&sort=activity&site=stackoverflow&access_token=my-access-token&key=my-key" | gunzip | jq '[.items[] | select(.is_accepted == false)]'
- 在这种情况下,
jq '[.items[] | select(.is_accepted == false)]'
用于检索的值. - 通过此修改,将检索带有
"is_accepted": false
的值. - In this case,
jq '[.items[] | select(.is_accepted == false)]'
is used for the retrieved values. - By this modification, the values with
"is_accepted": false
are retrieved. - 在此修改中,假设您的访问令牌和密钥可用于请求
https://api.stackexchange.com/2.2/users/10348758/answers
. - /answers/{ids} 的用法
- jq
- Usage of /answers/{ids}
- jq
这篇关于如何在用户级别的日期范围内获得所有不可接受的答案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!