如何在用户级别的日期范围内获得所有不可接受的答案?

问题描述:

通过使用以下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=*&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.

在文档中写道:

仅可查询已批准,已拒绝和接受的字段 带有带有private_info范围的access_token.

The upvoted, downvoted, and accepted fields can only be queried for with an access_token with the private_info scope.

因此,我还创建了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=*" | 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=*&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.
      • Usage of /answers/{ids}
      • jq