Exemplo n.º 1
0
def collectFriendsCheckins(threadName="") :

    timestamp = str(int(time.time()) - 60*60)    
    
    while True :
    
        print "[RECENT FRIENDS CHECKINS]"
        
        recent = foursquare.checkinsRecent(timestamp)
        try:
            if recent :            
                for checkin in recent['response']['recent'] :
                    print checkin['id'], checkin['user']['firstName'].encode('utf-8') 
                    ailoveStat.write(str(checkin))
                
                    # 1% chance to like
                    if random.randint(0, 100) == 33 :
                        foursquare.checkinsLike(checkin['id'])
        except Exception:
            f = open("Ailove.Error.log", "a")
            f.write(str(recent))
            f.close()
                   
        friendsTimestamp = str(int(time.time()))
        sys.stdout.flush()
        print "sleeping 5 min"
        time.sleep(60)
Exemplo n.º 2
0
def checkFriendsCheckins(threadName="") :
    
    global recentTimestamp

    while True :
        print "[CHECK FRIENDS CHECKINS]"
        recent = foursquare.checkinsRecent(recentTimestamp)
        if recent :            
            for checkin in recent['response']['recent'] :
                print checkin['id']
                # 10% chance to comment
                if random.randint(0, 100) > 90 :
                    checkinId  = str(checkin['id'])
                    categories = checkin['venue']['categories']
                    foursquare.checkinsLike(checkinId)
                    if len(categories) > 0 :
                        addRandomComment(checkinId, categories[0]['id'])
                           
        recentTimestamp = str(int(time.time()))

        print "sleeping 10 min"
        time.sleep(300)