From: Moritz Kiefer Date: Wed, 16 Jan 2013 14:17:35 +0000 (+0100) Subject: Add function to retrieve userinfo X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=554478149edff53c3864336a29c423c08362e39d;p=diaspy.git Add function to retrieve userinfo --- diff --git a/.gitignore b/.gitignore index 666aa6a..1ebd6c0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ *.swp docs/build/* __pycache__/* +.env diff --git a/diaspy.py b/diaspy.py index 66d9d38..9bbb3ee 100644 --- a/diaspy.py +++ b/diaspy.py @@ -9,6 +9,7 @@ """ import requests import re +import json class Client: """This is the client class to connect to diaspora. @@ -60,3 +61,13 @@ class Client: 'status_message[text]': text, 'authenticity_token': token} r = self._session.post(self._pod + "/status_messages", data=data) + + def getUserInfo(self): + """ This function return the current user's attributes + :returns dict -- json formatted user info + + """ + r = self._session.get(self._pod + "/stream") + regex = re.compile(r'window.current_user_attributes = ({.*})') + userdata = json.loads(regex.search(r.text).group(1)) + return userdata