From 2ab410e17d8c216281b1fc26773934e94e71cb96 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Thu, 17 Jan 2013 17:02:29 +0100 Subject: [PATCH] Add function to add and remove comments --- diaspy.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/diaspy.py b/diaspy.py index cfbba38..da8494f 100644 --- a/diaspy.py +++ b/diaspy.py @@ -123,4 +123,37 @@ class Client: 'authenticity_token': self._get_token()} r = self._session.post(self._pod + "/reshares", data=data) - print(r.text) + + def comment(self, post_id, text): + """This function comments on a post + + :param post_id: id of the post to comment on. + :type post_id: str + :param text: text to comment. + :type text: str + + """ + + data = {'text': text, + 'authenticity_token': self._get_token()} + + r = self._session.post(self._pod + "/posts/" + post_id + "/comments", data=data) + + return r.json() + + def rmcomment(self, post_id, comment_id): + """This function removes a comment from a post + + :param post_id: id of the post to remove the like from. + :type post_id: str + :param like_id: id of the like to remove. + :type like_id: str + + """ + + data = {'authenticity_token': self._get_token()} + + r = self._session.delete(self._pod + "/posts/" + + post_id + "/comments/" + + comment_id, + data=data) -- 2.25.1