问题
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.
In the documentation, it is written that :
The upvoted, downvoted, and accepted fields can only be queried for with an access_token with the private_info scope.
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&access_token=my-access-token&key=my-key" | gunzip
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 ?
Can anyone please tell me how can I retrieve a list of all my unaccepted answers (within a given date range) using Stack Exchange API.
回答1:
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.
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
.
Sample 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 | jq '[.items[] | select(.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.
Note:
- In this modification, it supposes that your access token and key can be used for requesting to
https://api.stackexchange.com/2.2/users/10348758/answers
.
References:
- Usage of /answers/{ids}
- jq
来源:https://stackoverflow.com/questions/62597464/get-all-unaccepted-answers-within-a-date-range-at-user-level-using-stack-exchang