Example #1
0
def grabLatest():
    number = 200
    # grab newst file
    files = sorted(os.listdir(path))
    latest = files[-1]
    # put one second past to not grab an entry that already exists
    last_timestamp = latest[:-5]
    append = "&limit=%s&afterTimestamp=%s" % (number, int(last_timestamp) + 1)
    response = foursquare.retrieve(token, append)
    if (len(response['data'])):
        timestamp = str(response['data'][0]['createdAt']) + ".json"
        write_file = path + timestamp
        with open(write_file, 'w') as output_file:
            json.dump(response, output_file)
    else:
        print ("No newer checks to grab!")
Example #2
0
def bulk_export():
    total_responses = float("inf")

    # prep vars for import
    offset = 0
    number = 200
    iterations = 0

    while(total_responses > 0):
        append = "&offset=%s&limit=%s" % (offset, number)
        time.sleep(10)

        response = foursquare.retrieve(token, append)
        timestamp = str(response['data'][0]['createdAt']) + ".json"
        write_file = path + timestamp
        with open(write_file, 'w') as output_file:
            json.dump(response, output_file)
        # store responses just once
        if (iterations == 0):
            total_responses = response['count']
        offset += number
        total_responses -= number
        iterations += 1
Example #3
0
 def test_checkins(self):
     checkins = foursquare.retrieve(KEY)
     self.assertIn('data', checkins)
     self.assertIn('count', checkins)
     self.assertIsInstance(checkins['data'], list)
     self.assertIsInstance(checkins['count'], int)