刷步数和人生重开模拟器

本贴最后更新于 1165 天前,其中的信息可能已经时移世易

最近在 B 站听到静总翻唱了《陀飞轮》,真真就太感人了吧。。"霎眼廿七岁,时日无多方不敢偷懒;宏愿纵未了,奋斗总不太晚。"哎,默默流泪。

一、刷步数

周末看了几个华米运动的接口,加上贴吧有老哥说可以调改步数接口然后同步到第三方,然后试了试,还真行,cover 了猪头的代码。服务端是用 php 写的,我参照码云上的一个 demo 用 java 开接口改了一下,api 参数返回都没问题,但是值就是不改,好无语。。。贴一下代码还有 cover 大佬改的页面。

改步数地址:http://www.jinyunlong.xyz/wx_step/

package com.jin.wx_step.Controller;

import cn.hutool.http.HttpRequest;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Splitter;
import com.jin.wx_step.Entity.User;
import com.jin.wx_step.Service.WxStepService;
import net.sf.json.JSONObject;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author jinyunlong
 * @date 2021/9/4 00:10
 * @profession ICBC锅炉房保安
 */
@RestController
@RequestMapping(value ="/wx_step")
public class WxStepController {

    @Autowired
    WxStepService wxStepService;

    private static ObjectMapper objectMapper = new ObjectMapper();

    private static CloseableHttpClient httpClient = HttpClientBuilder.create().build();

    @RequestMapping(value ="/update")
    public JSONObject update(User user){

        HashMap<String, String> map = new HashMap<>();
        String code = "x";
        String message = "未知错误";
        map.put("code",code);
        map.put("message",message);
        String username = user.getUsername();
        String pass = user.getPass();
        String accessCode = getAccessCode(username, pass);
        Map<String, String> login = login(accessCode);
        String login_token = login.get("login_token");
        String user_id = login.get("user_id");
        String appToken = getAppToken(login_token);
        JSONObject jsonObject = JSONObject.fromObject(map);
        try {
            String result = updateStep(appToken, user_id,user);
            jsonObject = JSONObject.fromObject(result);
            return jsonObject;
        } catch (IOException e) {
            e.printStackTrace();
        }
            Logger logger = Logger.getLogger("AnyLoggerName");
            logger.setLevel(Level.INFO);
            logger.info("logging message here!");
            return jsonObject;
    }

    public String getAccessCode(String account, String password) {
        try {
            URIBuilder builder = new URIBuilder("https://api-user.huami.com/registrations/+86" + account + "/tokens");
            HashMap<String, String> data = new HashMap<>();
            data.put("client_id", "HuaMi");
            data.put("password", password);
            data.put("redirect_uri", "https://s3-us-west-2.amazonaws.com/hm-registration/successsignin.html");
            data.put("token", "access");
            data.forEach(builder::setParameter);
            HttpPost httpPost = new HttpPost(builder.build());
            httpPost.setConfig(RequestConfig.custom()
                    .setSocketTimeout(5000)
                    ////默认允许自动重定向
                    .setRedirectsEnabled(false)
                    .build());
            httpPost.addHeader("User-Agent", "MiFit/4.6.0 (iPhone; iOS 14.0.1; Scale/2.00)");
            httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
            HttpResponse execute = httpClient.execute(httpPost);
            int statusCode = execute.getStatusLine().getStatusCode();
            Header location = execute.getFirstHeader("Location");
            String params = location.getValue().substring(location.getValue().indexOf("?") + 1);
            Map<String, String> split = Splitter.on("&").withKeyValueSeparator("=").split(params);
            String s = split.get("access");
            return s;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public Map<String, String> login(String accessCode) {
        try {
            HashMap<String, String> data1 = new HashMap<>();
            data1.put("app_version", "4.6.0");
            data1.put("code", accessCode);
            data1.put("country_code", "CN");
            data1.put("device_id", "2C8B4939-0CCD-4E94-8CBA-CB8EA6E613A1");
            data1.put("device_model", "phone");
            data1.put("grant_type", "access_token");
            data1.put("third_name", "huami_phone");
            data1.put("app_name", "com.xiaomi.hm.health");
            URIBuilder builder1 = new URIBuilder("https://account.huami.com/v2/client/login");
            data1.forEach(builder1::setParameter);
            HttpPost httpPost1 = new HttpPost(builder1.build());
            httpPost1.addHeader("User-Agent", "MiFit/4.6.0 (iPhone; iOS 14.0.1; Scale/2.00)");
            httpPost1.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
            HttpResponse execute1 = httpClient.execute(httpPost1);
            String s1 = EntityUtils.toString(execute1.getEntity());
            JsonNode jsonNode = objectMapper.readTree(s1);
            String login_token = jsonNode.get("token_info").get("login_token").asText();
            String user_id = jsonNode.get("token_info").get("user_id").asText();
            HashMap<String, String> map = new HashMap<>();
            map.put("login_token", login_token);
            map.put("user_id", user_id);
            return map;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String getAppToken(String login_token) {
        try {
            HttpGet httpGet = new HttpGet("https://account-cn.huami.com/v1/client/app_tokens?app_name=com.xiaomi.hm.health&dn=api-user.huami.com%2Capi-mifit.huami.com%2Capp-analytics.huami.com&login_token=" + login_token + "&os_version=4.1.0");
            CloseableHttpResponse execute3 = httpClient.execute(httpGet);
            String s3 = EntityUtils.toString(execute3.getEntity());
            String app_token = objectMapper.readTree(s3).get("token_info").get("app_token").asText();
            return app_token;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String updateStep(String appToken, String userId, User user) throws IOException {
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String format = simpleDateFormat.format(date);
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH");
        LocalDateTime localDateTime = LocalDateTime.now();
//        Integer step = new Random().nextInt(maxStep - minStep + 1) + minStep;
        Integer step = wxStepService.update(user);
        String jsonData = "[{\"summary\":\"{\\\"slp\\\":{\\\"ss\\\":73,\\\"lt\\\":304,\\\"dt\\\":0,\\\"st\\\":1589920140,\\\"lb\\\":36,\\\"dp\\\":92,\\\"is\\\":208,\\\"rhr\\\":0,\\\"stage\\\":[{\\\"start\\\":269,\\\"stop\\\":357,\\\"mode\\\":2},{\\\"start\\\":358,\\\"stop\\\":380,\\\"mode\\\":3},{\\\"start\\\":381,\\\"stop\\\":407,\\\"mode\\\":2},{\\\"start\\\":408,\\\"stop\\\":423,\\\"mode\\\":3},{\\\"start\\\":424,\\\"stop\\\":488,\\\"mode\\\":2},{\\\"start\\\":489,\\\"stop\\\":502,\\\"mode\\\":3},{\\\"start\\\":503,\\\"stop\\\":512,\\\"mode\\\":2},{\\\"start\\\":513,\\\"stop\\\":522,\\\"mode\\\":3},{\\\"start\\\":523,\\\"stop\\\":568,\\\"mode\\\":2},{\\\"start\\\":569,\\\"stop\\\":581,\\\"mode\\\":3},{\\\"start\\\":582,\\\"stop\\\":638,\\\"mode\\\":2},{\\\"start\\\":639,\\\"stop\\\":654,\\\"mode\\\":3},{\\\"start\\\":655,\\\"stop\\\":665,\\\"mode\\\":2}],\\\"ed\\\":1589943900,\\\"wk\\\":0,\\\"wc\\\":0},\\\"tz\\\":\\\"28800\\\",\\\"stp\\\":{\\\"runCal\\\":1,\\\"cal\\\":6,\\\"conAct\\\":0,\\\"stage\\\":[],\\\"ttl\\\":" + step + ",\\\"dis\\\":144,\\\"rn\\\":0,\\\"wk\\\":5,\\\"runDist\\\":4,\\\"ncal\\\":0},\\\"v\\\":5,\\\"goal\\\":8000}\",\"data\":[{\"stop\":1439,\"value\":\"WhQAUA0AUAAAUAAAUAAAUAAAUAAAWhQAUAYAcBEAUAYAUA8AUAsAUAYAUDIAUCQAUDkAUCkAUD4AUC0AUFcAUD8AUCkAUCEAUCwAUCsAUB4AUCQAUBsAUCcAUBQAUDcAUBoAUCYAUFcAUCAAUDkAUCEAWhQAWhQ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v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\\/v7+\",\"summary_hr\":\"{\\\"ct\\\":0,\\\"id\\\":[]}\",\"date\":\"" + format + "\"}]";
        HashMap<String, Object> dataUpdate = new HashMap<>();
        dataUpdate.put("data_json", jsonData);
        dataUpdate.put("userid", userId);
        dataUpdate.put("device_type", "0");
        dataUpdate.put("last_sync_data_time", "1589917081");
        dataUpdate.put("last_deviceid", "DA932FFFFE8816E7");
        HashMap<String, String> headers = new HashMap<>();
        headers.put("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.12(0x17000c2d) NetType/WIFI Language/zh_CN");
        headers.put("apptoken", appToken);
        headers.put("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
        HttpRequest post = HttpRequest.post("https://api-mifit-cn.huami.com/v1/data/band_data.json?&t=" + System.currentTimeMillis());
        post.addHeaders(headers);
        post.form(dataUpdate);
        String body = post.execute().body();
        System.out.println(body);
        return body;
    }

}

大部分是抄码云老哥的,搜不到了,抱歉。。。我做的只是做成接口供前端调了(但是返回 code 都是 1 不改值啊喂!)。service 和 entity 层不贴了,很简单。

看了看调用的几个接口,其实就是登录、换 token、修改,而且开发逻辑和微信啥的都很像,login_token 和 token 也都非常关键,不加赘述了。

二、人生重开模拟器

其实我一开始是部署在自己的服务器上了,但是玩了几次,rand 的结果都不好,索性之下,泄 ♂,不玩了!源码好像是日本人(更正是中国人,只是有日文版。。)写的:https://github.com/VickScarlet/

不过最近这几年日本人是有多喜欢人生重开然后重生在异世界啊喂!。。。

代码是纯前端,我看有好多 csv,没点开看,但逻辑应该就是用他来做随机吧,不了解了。记一下在 centos7 上遇到的几个坑:

我的 centos 上一开始是没有 node 的,然后装了一下,发现版本低,npm run dev 时报错,然后就升版本,然后就后台启动项目;

参考:1、Centos7 安装 NPM(此篇安装版本比较老了)

2、在 centos7 升级 nodejs 到最新版本(切完了版本别忘了把环境变量引到换的版本去嗷)

3、npm 升级到最新版本

4、npm run dev 后台运行

然后挂 ng 代一下也行。

还有我想在 npm run dev 时指定端口启动不知咋弄,用网上说的方法没试成唉。。。

这周末我到底干了什么啊喂。。。

  • 代码
    466 引用 • 631 回帖 • 9 关注

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...
  • jyl

    黄伟文真真太会写了 😆

  • 其他回帖
  • someone1764 1 赞同

    Eason 噶歌,后面的都好有哲理,《苦瓜》、《夕阳无限好》、《葡萄成熟时》、《陀飞轮》,哩几首我个人都比较 like

    1 回复

推荐标签 标签

  • 友情链接

    确认过眼神后的灵魂连接,站在链在!

    24 引用 • 373 回帖
  • RESTful

    一种软件架构设计风格而不是标准,提供了一组设计原则和约束条件,主要用于客户端和服务器交互类的软件。基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存等机制。

    30 引用 • 114 回帖 • 2 关注
  • 新人

    让我们欢迎这对新人。哦,不好意思说错了,让我们欢迎这位新人!
    新手上路,请谨慎驾驶!

    52 引用 • 228 回帖
  • Kafka

    Kafka 是一种高吞吐量的分布式发布订阅消息系统,它可以处理消费者规模的网站中的所有动作流数据。 这种动作(网页浏览,搜索和其他用户的行动)是现代系统中许多功能的基础。 这些数据通常是由于吞吐量的要求而通过处理日志和日志聚合来解决。

    36 引用 • 35 回帖
  • danl
    132 关注
  • 强迫症

    强迫症(OCD)属于焦虑障碍的一种类型,是一组以强迫思维和强迫行为为主要临床表现的神经精神疾病,其特点为有意识的强迫和反强迫并存,一些毫无意义、甚至违背自己意愿的想法或冲动反反复复侵入患者的日常生活。

    15 引用 • 161 回帖
  • 自由行
    10 关注
  • 博客

    记录并分享人生的经历。

    273 引用 • 2388 回帖
  • GitLab

    GitLab 是利用 Ruby 一个开源的版本管理系统,实现一个自托管的 Git 项目仓库,可通过 Web 界面操作公开或私有项目。

    46 引用 • 72 回帖
  • 工具

    子曰:“工欲善其事,必先利其器。”

    286 引用 • 729 回帖
  • Jenkins

    Jenkins 是一套开源的持续集成工具。它提供了非常丰富的插件,让构建、部署、自动化集成项目变得简单易用。

    53 引用 • 37 回帖
  • ZeroNet

    ZeroNet 是一个基于比特币加密技术和 BT 网络技术的去中心化的、开放开源的网络和交流系统。

    1 引用 • 21 回帖 • 638 关注
  • GitHub

    GitHub 于 2008 年上线,目前,除了 Git 代码仓库托管及基本的 Web 管理界面以外,还提供了订阅、讨论组、文本渲染、在线文件编辑器、协作图谱(报表)、代码片段分享(Gist)等功能。正因为这些功能所提供的便利,又经过长期的积累,GitHub 的用户活跃度很高,在开源世界里享有深远的声望,并形成了社交化编程文化(Social Coding)。

    209 引用 • 2031 回帖
  • 安装

    你若安好,便是晴天。

    132 引用 • 1184 回帖
  • HHKB

    HHKB 是富士通的 Happy Hacking 系列电容键盘。电容键盘即无接点静电电容式键盘(Capacitive Keyboard)。

    5 引用 • 74 回帖 • 471 关注
  • Dubbo

    Dubbo 是一个分布式服务框架,致力于提供高性能和透明化的 RPC 远程服务调用方案,是 [阿里巴巴] SOA 服务化治理方案的核心框架,每天为 2,000+ 个服务提供 3,000,000,000+ 次访问量支持,并被广泛应用于阿里巴巴集团的各成员站点。

    60 引用 • 82 回帖 • 595 关注
  • 黑曜石

    黑曜石是一款强大的知识库工具,支持本地 Markdown 文件编辑,支持双向链接和关系图。

    A second brain, for you, forever.

    15 引用 • 122 回帖
  • 正则表达式

    正则表达式(Regular Expression)使用单个字符串来描述、匹配一系列遵循某个句法规则的字符串。

    31 引用 • 94 回帖
  • Spring

    Spring 是一个开源框架,是于 2003 年兴起的一个轻量级的 Java 开发框架,由 Rod Johnson 在其著作《Expert One-On-One J2EE Development and Design》中阐述的部分理念和原型衍生而来。它是为了解决企业应用开发的复杂性而创建的。框架的主要优势之一就是其分层架构,分层架构允许使用者选择使用哪一个组件,同时为 JavaEE 应用程序开发提供集成的框架。

    944 引用 • 1459 回帖 • 17 关注
  • 30Seconds

    📙 前端知识精选集,包含 HTML、CSS、JavaScript、React、Node、安全等方面,每天仅需 30 秒。

    • 精选常见面试题,帮助您准备下一次面试
    • 精选常见交互,帮助您拥有简洁酷炫的站点
    • 精选有用的 React 片段,帮助你获取最佳实践
    • 精选常见代码集,帮助您提高打码效率
    • 整理前端界的最新资讯,邀您一同探索新世界
    488 引用 • 384 回帖 • 8 关注
  • 职场

    找到自己的位置,萌新烦恼少。

    127 引用 • 1705 回帖 • 1 关注
  • App

    App(应用程序,Application 的缩写)一般指手机软件。

    91 引用 • 384 回帖
  • 深度学习

    深度学习(Deep Learning)是机器学习的分支,是一种试图使用包含复杂结构或由多重非线性变换构成的多个处理层对数据进行高层抽象的算法。

    53 引用 • 40 回帖 • 2 关注
  • Chrome

    Chrome 又称 Google 浏览器,是一个由谷歌公司开发的网页浏览器。该浏览器是基于其他开源软件所编写,包括 WebKit,目标是提升稳定性、速度和安全性,并创造出简单且有效率的使用者界面。

    62 引用 • 289 回帖 • 1 关注
  • GitBook

    GitBook 使您的团队可以轻松编写和维护高质量的文档。 分享知识,提高团队的工作效率,让用户满意。

    3 引用 • 8 回帖 • 4 关注
  • 域名

    域名(Domain Name),简称域名、网域,是由一串用点分隔的名字组成的 Internet 上某一台计算机或计算机组的名称,用于在数据传输时标识计算机的电子方位(有时也指地理位置)。

    43 引用 • 208 回帖
  • abitmean

    有点意思就行了

    29 关注