Open szopin opened 5 years ago
Also I'm unable to retrieve comments for a given sid (whether using the ending of sid, or stoid), like for example: "stoid" : "371655", "sid" : "19/10/28/038228" should have 74 comments both: https://soylentnews.org/api.pl?m=comment&op=discussion&sid=371655 https://soylentnews.org/api.pl?m=comment&op=discussion&sid=038228 return empty (same for 19/10/28/038228 and using value from "discussion" : 34343)
Second one is solved here and live patched on prod as of this evening in commit 4274259. I'll look into the first as I get time.
The first issue is solved as main page is now searchable so &tid=1 returns the latest stories. The comment op now seems to work with the sid, but it seems to return only single comment from 2019-05-05 18:07:56 no matter what sid is passed, strange https://soylentnews.org/api.pl?m=comment&op=discussion&sid=19/11/15/0353242 https://soylentnews.org/api.pl?m=comment&op=discussion&sid=19/10/28/038228 Both return that one comment from 5/5/19 (and one from 2015 too: "
This is richardboegli from IRC.
")Partial PEBKAC, although the docs could be more explicit.
When I first used that when working on my API bindings, I almost fell for that trap too. The docs say the sid
key takes an stoid
only, not a sid
like many of the other calls. Therefore, your queries are both equivalent to https://soylentnews.org/api.pl?m=comment&op=discussion&sid=19
and not what you think. But, I've noticed that the "discussion" sid
is also different from the stoid
anyway. Therefore, my currently workaround is to use the m=story&op=single
call to get the mapping representing the story, and then use the discussion
key for the proper value for the m=comment&op=discussion
call.
I also want to point out that the https://soylentnews.org/api.pl?m=comment&op=discussion&sid=19
actually returns 3 comments, not one. The object returned is a mapping whose keys are 0
and the cid
of the comments in it. The value of the 0
key is the metadata about the discussion and the cid
values are the comments of the discussion (which is, incidentally, not identical to the information you get from the m=comment&op=single
call for that cid
).
Awesome stuff, thanks a ton, didn't check if discussionid works after TMB's update and it does indeed, after wasting like 5h chasing a non-issue (I guess I need to read some qml for dummies or something) I'm now able to fetch all the comments, thank you! Once I figure a nice way to present indents this will be an awesome feature (might also look at posting anon_coward comments, haven't looked too much into that yet though, anyone got experience posting from api? if it works the issue can be closed, thanks again!)
I have a few thoughts about that:
First is that sometimes something goes wrong (such as the call from the database is too slow, the connection times out, etc.) and the response is an empty 200, which means that the same API calls need to be made multiple times before you get the actual result. It is usually there on the second one, but the most I've had to do is five before getting what I've wanted.
Second is that @TheMightyBuzzard broke my code with that update, as it seems I coded around the missing "s" bug. But that does make me think that maybe the argument should be named something different and the docs reflected to update the real argument name. My thinking is that discussions have their own IDs that aren't equal to either the sid or stoid, and reusing those names might be misleading. I suppose the alternative would be having the API map the sid or stoid do the mapping for you. Or just leave it the way it is as GEFGW.
Before my VM I used for testing got trashed and I changed gears to being a passive API, I tried post stories and comments. Stories seemed to work well, but I remember having problems with comments. If my recollection is correct, you had to use the sid (the one with the slashes), not the discussion id or stoid, and there is a hidden pid argument to the call that allows replying to comments but I don't recall testing it (and a couple other hidden arguments that do other things in other APIs). In addition, the reskey
had to be generated more than the 10 seconds in the past specified by the docs (may have been clock skew or PEBKAC), so I defaulted to25 for waiting after requesting a reskey. This was all a bit ago, so its a bit hazy and should probably be tested.
edited to change post comment paragraph after checking my code.
Yep. 'discussions' is a table in the db that associates stories, journal entries, and polls with the comments made to them, so 'did' is what's going to be used once we get the API up to speed with things that aren't stories.
As for 'sid' and 'stoid' being confusing and even used incorrectly interchangeably in some places, I feel your pain. It's done that way in the rehash code as well but it's too much of a pain to fix when there are more important things on the table.
According to the ApiDocs for the story ops: You may also specify "tid" as an argument. But it seems to be required, using the example (https://soylentnews.org/api.pl?m=story&op=latest) to pull latest stories returns: "no such topic:". Trying to pull the latest stories from main page sadly also doesn't work with: "tid 1 is not searchable". Is there any way to pull latest stories from all topics, or is RSS the only way to do that right now?