Re-implement Facebook service to use OAuth2 and Graph API. This allows
[hermes] / package / src / org / maemo / hermes / engine / facebook / service.py
index 0db44ca..ff46c26 100644 (file)
@@ -32,7 +32,8 @@ class Service(org.maemo.hermes.engine.service.Service):
         friends = []
         if self._create_birthday_only:
             for friend in self._friends_without_contact:
-                friends.append(friend)
+                if friend.is_interesting():
+                    friends.append(friend)
                     
         return friends
     
@@ -77,20 +78,20 @@ class Service(org.maemo.hermes.engine.service.Service):
             if key in data and data[key]:
                 callback(data[key])
         
-        friends_data = self._get_friends_data()
+        friends_data = self.fb.get_friends()
         for data in friends_data:
             friend = Friend(data['name'])
         
-            if 'profile_url' not in data:
-                data['profile_url'] = "http://www.facebook.com/profile.php?id=" + str(data['uid'])
+            if 'link' not in data:
+                data['link'] = "http://www.facebook.com/profile.php?id=" + str(data['id'])
         
             if_defined(data, 'website', friend.add_url)
-            if_defined(data, 'profile_url', friend.add_url)
-            if_defined(data, 'birthday_date', friend.set_birthday_date)
+            if_defined(data, 'link', friend.add_url)
+            if_defined(data, 'birthday', friend.set_birthday_date)
 
-            if_defined(data, 'pic_big', friend.set_photo_url)
+            if_defined(data, 'picture', friend.set_photo_url)
             
-            url = data['profile_url']
+            url = data['link']
             friend.add_url(url)
             self._register_friend(friend)
 
@@ -157,11 +158,3 @@ class Service(org.maemo.hermes.engine.service.Service):
         self._friends_without_contact.discard(friend)
         self._friends_by_contact[contact] = friend
         self._contacts_by_friend[friend] = contact
-
-
-    # -----------------------------------------------------------------------
-    def _get_friends_data(self):
-        """Returns a list of dicts, where each dict represents the raw data
-           of a friend"""
-        
-        return self.fb.users.getInfo(self.fb.friends.get(), Service.attrs)