Commits

Andy Mikhailenko committed 338c22e

Added method for fetching user profile data.

  • Participants
  • Parent commits ade8ab0

Comments (0)

Files changed (1)

 # class VkAudioFile(object):
 #     """Represents VK audio file
 #     """
-    
+
 #     def __init__(self, p):
 #         """
 #         """
 #         self._sid = sid
 
 class dummy:   # Just for convenience
-    pass     
+    pass
 
 def json_vk_load(data):
     """A little helper to load data from userapi"""
     for arg in kwargs:
         if kwargs[arg].__class__ != dummy:    # That's a trick
             s = s + '%s=%s&' %(arg.lower(), kwargs[arg])  # lower is for allowing "reserved" keywords as keys
-            
+
     s = s + 'sid=%s' %sid
     return json_vk_load(s)
-    
+
 
 maxcount = 10000 # For getting messages. Userapi is weird.
 
 class VkMessage(object):
     """Vkontakte basic message
     """
-    
+
     def __init__(self, message, sid):
         """
 
 
     def sender(self):
         return VkUser(self._mess[3][0], self._sid)
-     
+
     def time(self):
         return int(self._mess[1])
 
 
     def __repr__(self):
         return "'%s'" %self.content().encode('utf8')   # Dirty, but it's needed
-      
-        
+
+
 class VkWall(object):
     """Profile's wall
     """
 
     def messages(self, first=0, last=maxcount):
         """Gets messages
-        
+
         Arguments:
         - `first`:
         - `last`:
 class VkUser(object):
     """Represents VK user
     """
-    
+
     def __init__(self, vkid, sid):
         """
-        
+
         Arguments:
         - `vkid`: VK id
         - `sid`: userapi sid
         self._vkid = vkid
         self._sid = sid
 
+    def profile(self):
+        return vk_request(self._sid, Act='profile', id=self._vkid)
+
     def wall(self):
         """
-        
+
         """
         return VkWall(self._vkid, self._sid)
 
         """
         if act == "message" and user == dummy():
             pass # TODO
-        
+
         raw_messages = vk_request(self._sid, Act=act, From=first, To=last, Id=user)
 
         messages = [VkMessage(i, self._sid) for i in raw_messages['d']]
 
-        return messages        
+        return messages
 
     def friends(self, first=0, last=dummy()):
         raw_friends_list = vk_request(self._sid, Act='friends', From=first, To=last, Id=self._vkid)
         photos = [VkPhoto(x, self._sid) for x in raw_photos_list['d']]
         return photos
 
-    
+
 class VkClient(object):
     """Client for vkontakte.ru
     """
-    
+
     def __init__(self, username):
         """
-        
+
         Arguments:
         - `username`:
         """
         """Performs authentification with given password
         """
         url = urllib2.urlopen(r"http://login.userapi.com/auth", data="login=force&site=2​&email=%s&pass=%s" %(self._username, password))
-        
+
         if url.geturl().count('sid') > 0:
             self._sid = url.geturl().split('sid=')[1]
         else:
         """
         """
         return VkUser(vkid, self._sid)
-        
 
+