From 554478149edff53c3864336a29c423c08362e39d Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 16 Jan 2013 15:17:35 +0100 Subject: [PATCH] Add function to retrieve userinfo --- .gitignore | 1 + diaspy.py | 11 +++++++++++ 2 files changed, 12 insertions(+) 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 -- 2.25.1