@@ -0,0 +1,2856 @@
+import facebook%0A%0A%0Aclass ReactionEnum(enumerate):%0A    LIKE = 'LIKE'%0A    LOVE = 'LOVE'%0A    HAHA = 'HAHA'%0A    WOW = 'WOW'%0A    SAD = 'SAD'%0A    ANGRY = 'ANGRY'%0A%0A%0Aclass FacebookKnowledge(object):%0A    def __init__(self):%0A        # https://developers.facebook.com/tools/accesstoken/%0A        self.user_token = %5C%0A            %22EAAa4YDLtrSMBAELcZCGmzroCZBQuC04HlPs4yV95XbjdKBGLR%22 %5C%0A            %22YCyCGMTABniflPnPkBWTwdV7q9PU5zViHDmLQs2r8kZBKgC9di%22 %5C%0A            %223a0f8z7hBjElZC1u7k98vAXOxcduZCJCnnvX7LklyH6PoPxd8G%22%0A%0A        # Facebook API Version%0A        self.version = %222.8%22%0A        self.data = None%0A%0A    def get_last_post_info(self):%0A        graph = facebook.GraphAPI(access_token=self.user_token,%0A                                  version=self.version)%0A%0A        info = graph.get_object(id='me?fields=feed.limit(1)%7B'%5C%0A                                'message,story,comments.limit(10)%7B'%5C%0A                                'created_time,from%7Bname,id%7D,message,id%7D,'%5C%0A                                'reactions%7D')%0A%0A        if info%5B'feed'%5D%5B'data'%5D:%0A            self.data = info%5B'feed'%5D%5B'data'%5D%5B0%5D%0A%0A        return self.data%0A%0A    def get_reactions(self):%0A        if self.data:%0A            return self.data%5B'reactions'%5D%5B'data'%5D%0A        else:%0A            return None%0A%0A    def get_reactions_count(self):%0A        reactions = self.get_reactions()%0A%0A        if reactions:%0A            like, love, haha, wow, sad, angry = 0, 0, 0, 0, 0, 0%0A%0A            for reaction in reactions:%0A                if ReactionEnum.LIKE == reaction%5B'type'%5D:%0A                    like += 1%0A                elif ReactionEnum.LOVE == reaction%5B'type'%5D:%0A                    love += 1%0A                elif ReactionEnum.HAHA == reaction%5B'type'%5D:%0A                    haha += 1%0A                elif ReactionEnum.WOW == reaction%5B'type'%5D:%0A                    wow += 1%0A                elif ReactionEnum.SAD == reaction%5B'type'%5D:%0A                    sad += 1%0A                elif ReactionEnum.ANGRY == reaction%5B'type'%5D:%0A                    angry += 1%0A%0A            return %7B%0A                'like': like,%0A                'love': love,%0A                'haha': haha,%0A                'wow': wow,%0A                'sad': sad,%0A                'angry': angry,%0A            %7D%0A        else:%0A            return None%0A%0A    def get_comments(self):%0A        if self.data:%0A            return self.data%5B'comments'%5D%5B'data'%5D%0A        else:%0A            return None%0A%0A    def get_comments_count(self):%0A        comments = self.get_comments()%0A%0A        if comments:%0A            return len(comments)%0A        else:%0A            return 0%0A%0A%0Aif __name__ == %22__main__%22:%0A    fbk = FacebookKnowledge()%0A    data = fbk.get_last_post_info()%0A%0A    if data:%0A        try:%0A            message = data%5B'message'%5D%0A        except KeyError:%0A            message = data%5B'story'%5D%0A%0A        reactions_count = fbk.get_reactions_count()%0A%0A        print(fbk.get_comments_count())%0A%0A

Add facebookknowledge module