刷步数和人生重开模拟器

本贴最后更新于 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 关注

相关帖子

欢迎来到这里!

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

注册 关于
请输入回帖内容 ...
  • someone1764 1 赞同

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

    1 回复
  • jyl

    黄伟文真真太会写了 😆

推荐标签 标签

  • 倾城之链
    23 引用 • 66 回帖 • 137 关注
  • Postman

    Postman 是一款简单好用的 HTTP API 调试工具。

    4 引用 • 3 回帖 • 3 关注
  • 又拍云

    又拍云是国内领先的 CDN 服务提供商,国家工信部认证通过的“可信云”,乌云众测平台认证的“安全云”,为移动时代的创业者提供新一代的 CDN 加速服务。

    21 引用 • 37 回帖 • 545 关注
  • Git

    Git 是 Linux Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。

    209 引用 • 358 回帖
  • Facebook

    Facebook 是一个联系朋友的社交工具。大家可以通过它和朋友、同事、同学以及周围的人保持互动交流,分享无限上传的图片,发布链接和视频,更可以增进对朋友的了解。

    4 引用 • 15 回帖 • 453 关注
  • API

    应用程序编程接口(Application Programming Interface)是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力,而又无需访问源码,或理解内部工作机制的细节。

    77 引用 • 430 回帖 • 2 关注
  • 单点登录

    单点登录(Single Sign On)是目前比较流行的企业业务整合的解决方案之一。SSO 的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。

    9 引用 • 25 回帖
  • WiFiDog

    WiFiDog 是一套开源的无线热点认证管理工具,主要功能包括:位置相关的内容递送;用户认证和授权;集中式网络监控。

    1 引用 • 7 回帖 • 587 关注
  • OAuth

    OAuth 协议为用户资源的授权提供了一个安全的、开放而又简易的标准。与以往的授权方式不同之处是 oAuth 的授权不会使第三方触及到用户的帐号信息(如用户名与密码),即第三方无需使用用户的用户名与密码就可以申请获得该用户资源的授权,因此 oAuth 是安全的。oAuth 是 Open Authorization 的简写。

    36 引用 • 103 回帖 • 9 关注
  • V2Ray
    1 引用 • 15 回帖 • 1 关注
  • golang

    Go 语言是 Google 推出的一种全新的编程语言,可以在不损失应用程序性能的情况下降低代码的复杂性。谷歌首席软件工程师罗布派克(Rob Pike)说:我们之所以开发 Go,是因为过去 10 多年间软件开发的难度令人沮丧。Go 是谷歌 2009 发布的第二款编程语言。

    497 引用 • 1387 回帖 • 283 关注
  • 旅游

    希望你我能在旅途中找到人生的下一站。

    90 引用 • 899 回帖
  • 周末

    星期六到星期天晚,实行五天工作制后,指每周的最后两天。再过几年可能就是三天了。

    14 引用 • 297 回帖
  • 心情

    心是产生任何想法的源泉,心本体会陷入到对自己本体不能理解的状态中,因为心能产生任何想法,不能分出对错,不能分出自己。

    59 引用 • 369 回帖
  • 房星科技

    房星网,我们不和没有钱的程序员谈理想,我们要让程序员又有理想又有钱。我们有雄厚的房地产行业线下资源,遍布昆明全城的 100 家门店、四千地产经纪人是我们坚实的后盾。

    6 引用 • 141 回帖 • 585 关注
  • 链书

    链书(Chainbook)是 B3log 开源社区提供的区块链纸质书交易平台,通过 B3T 实现共享激励与价值链。可将你的闲置书籍上架到链书,我们共同构建这个全新的交易平台,让闲置书籍继续发挥它的价值。

    链书社

    链书目前已经下线,也许以后还有计划重制上线。

    14 引用 • 257 回帖
  • V2EX

    V2EX 是创意工作者们的社区。这里目前汇聚了超过 400,000 名主要来自互联网行业、游戏行业和媒体行业的创意工作者。V2EX 希望能够成为创意工作者们的生活和事业的一部分。

    17 引用 • 236 回帖 • 325 关注
  • SSL

    SSL(Secure Sockets Layer 安全套接层),及其继任者传输层安全(Transport Layer Security,TLS)是为网络通信提供安全及数据完整性的一种安全协议。TLS 与 SSL 在传输层对网络连接进行加密。

    70 引用 • 193 回帖 • 432 关注
  • C

    C 语言是一门通用计算机编程语言,应用广泛。C 语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。

    85 引用 • 165 回帖 • 1 关注
  • Latke

    Latke 是一款以 JSON 为主的 Java Web 框架。

    71 引用 • 535 回帖 • 786 关注
  • Kafka

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

    36 引用 • 35 回帖
  • CloudFoundry

    Cloud Foundry 是 VMware 推出的业界第一个开源 PaaS 云平台,它支持多种框架、语言、运行时环境、云平台及应用服务,使开发人员能够在几秒钟内进行应用程序的部署和扩展,无需担心任何基础架构的问题。

    5 引用 • 18 回帖 • 167 关注
  • ngrok

    ngrok 是一个反向代理,通过在公共的端点和本地运行的 Web 服务器之间建立一个安全的通道。

    7 引用 • 63 回帖 • 624 关注
  • 创业

    你比 99% 的人都优秀么?

    84 引用 • 1399 回帖 • 1 关注
  • Java

    Java 是一种可以撰写跨平台应用软件的面向对象的程序设计语言,是由 Sun Microsystems 公司于 1995 年 5 月推出的。Java 技术具有卓越的通用性、高效性、平台移植性和安全性。

    3187 引用 • 8213 回帖
  • Lute

    Lute 是一款结构化的 Markdown 引擎,支持 Go 和 JavaScript。

    25 引用 • 191 回帖 • 16 关注
  • TextBundle

    TextBundle 文件格式旨在应用程序之间交换 Markdown 或 Fountain 之类的纯文本文件时,提供更无缝的用户体验。

    1 引用 • 2 回帖 • 47 关注