Exemplo n.º 1
0
    def get (self, albumId):
        albums = []

        if self.current_user:
            user = User.get_user_by_id (self.current_user["id"])

            graph = facebook.GraphAPI (user.access_token)
            userInfo = graph.get_object ("%s" % user.id)

            if albumId:
                result = Album.query (albumId, ancestor = user.key).fetch ()
            else:
                result = [
                    {"id": album.key.id(), "name": album.name, "cover":
                        base64.b64encode (album.cover if album.cover else '')} 
                    for album in user.albums
                ]
            """
            all_albums = self.graph ('me/albums')
            
            if all_albums:
                print albums
                albums = [
                    dict (
                        name = album["name"],
                        icon = self.graph (album["cover_photo"]),
                        dikt = album
                    ) for album in all_albums["data"]
                ]
            """
        else:
            pass

        self.response.out.write (json.dumps (result))
Exemplo n.º 2
0
    def get (self, albumId):
        result = []

        if self.current_user:
            user = User.get_user_by_id (self.current_user["id"])

            graph = facebook.GraphAPI (user.access_token)
            userInfo = graph.get_object ("%s" % user.id)

            if albumId:
                result = Album.query (albumId, ancestor = user.key).fetch ()
            else:
                result = [
                    {"id": album.key.id(), "name": album.name, "cover": "/image/%s" % album.cover}
                    for album in user.albums
                ]
        else:
            pass

        self.response.out.write (json.dumps (result))