Backend Development 8 min read

Python Script to Automatically Modify Steps in Lifesense Health App for WeChat and Alipay Rankings

This guide explains how to install the Lifesense Health app, synchronize its data with WeChat and Alipay, and run a Python script that automatically changes the recorded step count each day, enabling users to dominate step‑ranking leaderboards without actually walking.

Top Architect
Top Architect
Top Architect
Python Script to Automatically Modify Steps in Lifesense Health App for WeChat and Alipay Rankings

The article presents a method for users who want to collect a large amount of energy in Alipay Ant Forest or top the WeChat step‑ranking leaderboard without physically walking, by using a Python script to modify the step count recorded by the Lifesense Health app.

Project significance : By automating step data, users can contribute to environmental greening via Ant Forest or flaunt high step numbers on WeChat without leaving the house.

Implementation method : Install the third‑party Lifesense Health app on a mobile device, register an account, and enable data synchronization to both WeChat and Alipay. Then run a Python script that remotely changes the step count associated with the logged‑in Lifesense account.

Step‑by‑step instructions :

1. Install the Lifesense Health app (Android: http://app.mi.com/details?id=gz.lifesense.weidong ; iOS: https://apps.apple.com/us/app/lifesense-health/id1479525632 ).

2. Register an account and set a password.

3. Complete the third‑party sync so that exercise data is uploaded to WeChat and Alipay.

4. Execute the Python script to modify the step count.

Python code : The script logs in to the Lifesense service, obtains a user ID and access token, and then uploads a fabricated step record. It is scheduled to run daily at 7 AM (25200 seconds after midnight). Users should replace the placeholders for username, password, and desired step count (recommended 30,000–90,000). Changing the value 25200 adjusts the execution time.

# -*- coding: utf-8 -*-
import requests
import json
import hashlib
import time
import datetime

class LexinSport:
    def __init__(self, username, password, step):
        self.username = username
        self.password = password
        self.step = step

    # 登录
    def login(self):
        url = 'https://sports.lifesense.com/sessions_service/login?systemType=2&version=4.6.7'
        data = {'loginName': self.username,
                'password': hashlib.md5(self.password.encode('utf8')).hexdigest(),
                'clientId': '49a41c9727ee49dda3b190dc907850cc',
                'roleType': 0,
                'appType': 6}
        headers = {'Content-Type': 'application/json; charset=utf-8',
                   'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 7.1.2; LIO-AN00 Build/LIO-AN00)'}
        response_result = requests.post(url, data=json.dumps(data), headers=headers)
        if response_result.status_code == 200:
            resp = json.loads(response_result.text)
            user_id = resp['data']['userId']
            access_token = resp['data']['accessToken']
            return user_id, access_token
        else:
            return '登录失败'

    # 修改步数
    def change_step(self):
        login_result = self.login()
        if login_result == '登录失败':
            return '登录失败'
        url = 'https://sports.lifesense.com/sport_service/sport/sport/uploadMobileStepV2?systemType=2&version=4.6.7'
        data = {'list': [{
            'DataSource': 2,
            'active': 1,
            'calories': int(self.step/4),
            'dataSource': 2,
            'deviceId': 'M_NULL',
            'distance': int(self.step/3),
            'exerciseTime': 0,
            'isUpload': 0,
            'measurementTime': time.strftime('%Y-%m-%d %H:%M:%S'),
            'priority': 0,
            'step': self.step,
            'type': 2,
            'updated': int(round(time.time() * 1000)),
            'userId': login_result[0]
        }]}
        headers = {'Content-Type': 'application/json; charset=utf-8',
                   'Cookie': f'accessToken={login_result[1]}'}
        response_result = requests.post(url, data=json.dumps(data), headers=headers)
        if response_result.status_code == 200:
            return f'修改步数为【{self.step}】成功'
        else:
            return '修改步数失败'

def get_sleep_time():
    tomorrow = datetime.date.today() + datetime.timedelta(days=1)
    tomorrow_run_time = int(time.mktime(time.strptime(str(tomorrow), '%Y-%m-%d'))) + 25200
    current_time = int(time.time())
    return tomorrow_run_time - current_time

if __name__ == "__main__":
    fail_num = 3
    while True:
        while fail_num > 0:
            try:
                result = LexinSport('乐心健康账号', '乐心健康密码', 50000).change_step()
                print(result)
                break
            except Exception as e:
                print(f'运行出错,原因: {e}')
                fail_num -= 1
                if fail_num == 0:
                    print('修改步数失败')
        fail_num = 3
        sleep_time = get_sleep_time()
        time.sleep(sleep_time)

Note: The script modifies the current day's steps immediately; automatic daily updates start from the next day after the script remains running. The full source code and related files can be obtained by replying to the QR code shown at the end of the article.

PythonautomationAPIWeChathealthAlipaystep-fake
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.