Example #1
0
 def analyzeUserFeed(self, user_fbid):
     fqlstr = '{"query1": "SELECT post_id, actor_id, target_id, tagged_ids FROM stream WHERE source_id=%s AND app_id=\'\' LIMIT 100", "query2": "SELECT fromid from comment WHERE post_id IN (SELECT post_id FROM #query1)"}' %(user_fbid)
     fb_response = self.open_facebook.fql(fqlstr)
     wall_updates = get_data_arr(fb_response)[0]['fql_result_set']
     comments = get_data_arr(fb_response)[1]['fql_result_set']
     user_freq={}
     for update in wall_updates:
         if str(update['actor_id']) != str(user_fbid):
             print "1",update['actor_id']
             if str(update['actor_id']) not in user_freq:
                 user_freq[str(update['actor_id'])] = 0
             user_freq[str(update['actor_id'])] += 1
             continue
         else:
             if update['target_id'] is not None and str(update['target_id']) != str(user_fbid):
                 if update['target_id'] not in user_freq:
                     user_freq[update['target_id']] = 0
                 user_freq[update['target_id']] += 1
             for tag_id in update['tagged_ids']:
                 if str(tag_id) != str(user_fbid):
                     if str(tag_id) not in user_freq:
                         user_freq[str(tag_id)] = 0
                     user_freq[str(tag_id)] += 1
         
     for com in comments:
         if str(com['fromid']) != str(user_fbid):
             if str(com['fromid']) not in user_freq:
                 user_freq[str(com['fromid'])] = 0
             user_freq[str(com['fromid'])] += 1
     return user_freq
Example #2
0
    def analyzeUserFeed(self, user_fbid):
        fqlstr = '{"query1": "SELECT post_id, actor_id, target_id, tagged_ids FROM stream WHERE source_id=%s AND app_id=\'\' LIMIT 100", "query2": "SELECT fromid from comment WHERE post_id IN (SELECT post_id FROM #query1)"}' % (
            user_fbid)
        fb_response = self.open_facebook.fql(fqlstr)
        wall_updates = get_data_arr(fb_response)[0]['fql_result_set']
        comments = get_data_arr(fb_response)[1]['fql_result_set']
        user_freq = {}
        for update in wall_updates:
            if str(update['actor_id']) != str(user_fbid):
                print "1", update['actor_id']
                if str(update['actor_id']) not in user_freq:
                    user_freq[str(update['actor_id'])] = 0
                user_freq[str(update['actor_id'])] += 1
                continue
            else:
                if update['target_id'] is not None and str(
                        update['target_id']) != str(user_fbid):
                    if update['target_id'] not in user_freq:
                        user_freq[update['target_id']] = 0
                    user_freq[update['target_id']] += 1
                for tag_id in update['tagged_ids']:
                    if str(tag_id) != str(user_fbid):
                        if str(tag_id) not in user_freq:
                            user_freq[str(tag_id)] = 0
                        user_freq[str(tag_id)] += 1

        for com in comments:
            if str(com['fromid']) != str(user_fbid):
                if str(com['fromid']) not in user_freq:
                    user_freq[str(com['fromid'])] = 0
                user_freq[str(com['fromid'])] += 1
        return user_freq
Example #3
0
    def get_friends(self, limit=1000):
        '''
        Connects to the facebook api and gets the users friends
        '''
        friends = getattr(self, '_friends', None)
        if friends is None:
            friends_response = self.open_facebook.fql("SELECT uid, name, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) LIMIT %s" % limit)
            #friends_response = self.open_facebook.get('me/friends', limit=limit)
	    friends_temp = get_data_arr(friends_response)
            friends=[]
            for response_dict in friends_temp:
                response_dict['id'] = response_dict['uid']
                friends.append(response_dict)
        
	logger.info('found %s friends', len(friends))
        return friends
Example #4
0
    def get_friends(self, limit=1000):
        '''
        Connects to the facebook api and gets the users friends
        '''
        friends = getattr(self, '_friends', None)
        if friends is None:
            friends_response = self.open_facebook.fql(
                "SELECT uid, name, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) LIMIT %s"
                % limit)
            #friends_response = self.open_facebook.get('me/friends', limit=limit)
            friends_temp = get_data_arr(friends_response)
            friends = []
            for response_dict in friends_temp:
                response_dict['id'] = response_dict['uid']
                friends.append(response_dict)

        logger.info('found %s friends', len(friends))
        return friends