【PYTHON】乐心健康刷微信支付宝步数

本文最后更新于:2020年10月5日 晚上

lx-step

【Python】腾讯云云函数配合乐心健康刷QQ、微信、支付宝步数(支持随机步数、微信QQ推送)

方法

  1. 下载乐心健康APP:官方下载地址:http://www.lifesense.com/app/
  2. 从应用商店下载乐心健康App,打开软件并选择手机号登录
  3. 登录之后,点击我的->设置->账号与安全->设置密码(修改密码),设置你自己记得住的密码
  4. 回到App首页,点击我的->数据共享,绑定你想同步数据的项目注:同步微信运动请按照要求关注【乐心运动】公众号。
  5. 回到云函数代码,配置好下图参数,运行即可提交步数即可同步至你绑定的所有平台
    1
  6. 设置好云函数触发规则

其他

https://www.52pojie.cn/thread-1274977-1-1.html

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# -*- coding: utf8 -*-
import requests
import hashlib
import json
import time
import random

def md5(code):
res=hashlib.md5()
res.update(code.encode("utf8"))
return res.hexdigest()

def get_information(mobile,password):
header = {
'Content-Type': 'application/json; charset=utf-8',
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
}
url="http://sports.lifesense.com/sessions_service/login?systemType=2&version=4.6.7"
datas = {
"appType":6,
"clientId":md5("5454"),
"loginName":str(mobile),
"password":md5(str(password)),
"roleType":0
}
response =requests.post(url,headers=header,data=json.dumps(datas))
return response.text

def update_step(step,information):
step =int(step)
url="http://sports.lifesense.com/sport_service/sport/sport/uploadMobileStepV2?version=4.5&systemType=2"
accessToken=json.loads(information)["data"]["accessToken"]
userId=json.loads(information)["data"]["userId"]
#print(accessToken)
#print(userId)
#获取当前时间和日期
timeStamp=time.time()
localTime = time.localtime(timeStamp)
strTime = time.strftime("%Y-%m-%d %H:%M:%S", localTime)
print(strTime)
measureTime=strTime+","+str(int(timeStamp))

header = {
'Cookie': 'accessToken='+accessToken,
'Content-Type': 'application/json; charset=utf-8',
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
}
sport_datas = {
"list": [
{
"DataSource":2,
"active":1,
"calories":str(int(step/4)),
"dataSource":2,
"deviceId":"M_NULL",
"distance":str(int(step/3)),
"exerciseTime":0,
"isUpload":0,
"measurementTime":measureTime,
"priority":0,
"step": str(step),
"type":2,
"updated":str(int(time.time()*1000)),
"userId":str(userId)
}]
}
result=requests.post(url,headers=header,data=json.dumps(sport_datas))
return result.text

def server_send(msg):
if sckey == '':
return
server_url = "https://sc.ftqq.com/" + str(sckey) + ".send"
data = {
'text': msg,
'desp': msg
}
requests.post(server_url, data=data)

def kt_send(msg):
if ktkey == '':
return
kt_url = 'https://push.xuthus.cc/send/'+str(ktkey)
data = ('步数刷取完成,请查看详细信息~\n'+str(msg)).encode("utf-8")
requests.post(kt_url, data=data)

def execute_walk(phone,password,step):
information=get_information(phone,password)
update_result=update_step(step,information)
result=json.loads(update_result)["msg"]
if result == '成功':
msg = "刷新步数成功!此次刷取" + str(step) + "步。"
print(msg)
server_send(msg)
kt_send(msg)
else:
msg = "刷新步数失败!请查看云函数日志。"
print(msg)
server_send(msg)
kt_send(msg)


def main():
if phone and password and step != '':
execute_walk(phone, password, step)
else:
print("参数不全,请指定参数。或者在调用中直接指定参数")

# -- 配置 --
# ------------------------------
phone = '' # 登陆账号
password = '' # 密码
step = random.randint(30000,40000) # 随机30000-40000步数
sckey = '' # server酱key(可空)
ktkey = '' # 酷推key(可空)
# ------------------------------

def main_handler(event, context):
return main()

if __name__ == '__main__':
main()