nborrmann / jodel_api

Unoffical Python Interface to the Jodel API
MIT License
149 stars 33 forks source link

Get Comments for post_id #66

Closed andrelanger closed 6 years ago

andrelanger commented 6 years ago

Hello everybody,

when I invoke j.get_post_details_v3(post_id, skip=0), it returns me a property "child_count" with the correct number of comments. However, the array in the property "children" is always empty.

So how do I retrieve the comment messages for a particular Jodel post_id?

André

nborrmann commented 6 years ago

You need to use skip=None

On Feb 28, 2018 14:03, "André Langer" notifications@github.com wrote:

Hello everybody,

when I invoke j.get_post_details_v3(post_id, skip=0), it returns me a property "child_count" with the correct number of comments. However, the array in the property "children" is always empty.

So how do I retrieve the comment messages for a particular Jodel post_id?

André

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nborrmann/jodel_api/issues/66, or mute the thread https://github.com/notifications/unsubscribe-auth/ABpLKF9dHSRF6wldB8Xkqzbizyb9L8V5ks5tZU6ggaJpZM4SWnh- .

andrelanger commented 6 years ago

Thanks for the immediate reply.

You need to use skip=None

I tested it, but the returned "children" array is still empty for j.get_post_details_v3(post_id, skip=None). Does it work correctly for you?

petrekova commented 6 years ago

If you're looking for the comments, you will find them in the replies node. The children node always is empty, even when you look up posts. Maybe it's a placeholder for future features.

So to retrieve an array of all comments of a post, your code could be something like this:

# initialize jodel_api beforehand
# Let's also assume that we have somehow retrieved a post_id with some comments

x = j.get_post_details_v3(post_id)
# comments are saved in array
comments = x[1]["replies"]
# take a look by prettyprinting them in the console (or a file if you want)
print json.dumps(comments,indent=4,sort_keys=True)
andrelanger commented 6 years ago

Thanks for your comment, petrekova.

I only evaluated x[1]["details"] and was not aware of the other key "replies" so far. That helped me a lot.

petrekova commented 6 years ago

Glad I could help @andrelanger