刷步数和人生重开模拟器

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

    黄伟文真真太会写了 😆

推荐标签 标签

  • Swagger

    Swagger 是一款非常流行的 API 开发工具,它遵循 OpenAPI Specification(这是一种通用的、和编程语言无关的 API 描述规范)。Swagger 贯穿整个 API 生命周期,如 API 的设计、编写文档、测试和部署。

    26 引用 • 35 回帖 • 1 关注
  • 工具

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

    286 引用 • 729 回帖
  • 安全

    安全永远都不是一个小问题。

    199 引用 • 816 回帖 • 1 关注
  • Oracle

    Oracle(甲骨文)公司,全称甲骨文股份有限公司(甲骨文软件系统有限公司),是全球最大的企业级软件公司,总部位于美国加利福尼亚州的红木滩。1989 年正式进入中国市场。2013 年,甲骨文已超越 IBM,成为继 Microsoft 后全球第二大软件公司。

    105 引用 • 127 回帖 • 382 关注
  • H2

    H2 是一个开源的嵌入式数据库引擎,采用 Java 语言编写,不受平台的限制,同时 H2 提供了一个十分方便的 web 控制台用于操作和管理数据库内容。H2 还提供兼容模式,可以兼容一些主流的数据库,因此采用 H2 作为开发期的数据库非常方便。

    11 引用 • 54 回帖 • 654 关注
  • 周末

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

    14 引用 • 297 回帖 • 1 关注
  • CSDN

    CSDN (Chinese Software Developer Network) 创立于 1999 年,是中国的 IT 社区和服务平台,为中国的软件开发者和 IT 从业者提供知识传播、职业发展、软件开发等全生命周期服务,满足他们在职业发展中学习及共享知识和信息、建立职业发展社交圈、通过软件开发实现技术商业化等刚性需求。

    14 引用 • 155 回帖
  • Postman

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

    4 引用 • 3 回帖 • 3 关注
  • iOS

    iOS 是由苹果公司开发的移动操作系统,最早于 2007 年 1 月 9 日的 Macworld 大会上公布这个系统,最初是设计给 iPhone 使用的,后来陆续套用到 iPod touch、iPad 以及 Apple TV 等产品上。iOS 与苹果的 Mac OS X 操作系统一样,属于类 Unix 的商业操作系统。

    85 引用 • 139 回帖 • 1 关注
  • SSL

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

    70 引用 • 193 回帖 • 431 关注
  • Sym

    Sym 是一款用 Java 实现的现代化社区(论坛/BBS/社交网络/博客)系统平台。

    下一代的社区系统,为未来而构建

    524 引用 • 4601 回帖 • 700 关注
  • Unity

    Unity 是由 Unity Technologies 开发的一个让开发者可以轻松创建诸如 2D、3D 多平台的综合型游戏开发工具,是一个全面整合的专业游戏引擎。

    25 引用 • 7 回帖 • 173 关注
  • Hibernate

    Hibernate 是一个开放源代码的对象关系映射框架,它对 JDBC 进行了非常轻量级的对象封装,使得 Java 程序员可以随心所欲的使用对象编程思维来操纵数据库。

    39 引用 • 103 回帖 • 709 关注
  • FFmpeg

    FFmpeg 是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。

    23 引用 • 32 回帖
  • LaTeX

    LaTeX(音译“拉泰赫”)是一种基于 ΤΕΧ 的排版系统,由美国计算机学家莱斯利·兰伯特(Leslie Lamport)在 20 世纪 80 年代初期开发,利用这种格式,即使使用者没有排版和程序设计的知识也可以充分发挥由 TeX 所提供的强大功能,能在几天,甚至几小时内生成很多具有书籍质量的印刷品。对于生成复杂表格和数学公式,这一点表现得尤为突出。因此它非常适用于生成高印刷质量的科技和数学类文档。

    12 引用 • 54 回帖 • 65 关注
  • 大疆创新

    深圳市大疆创新科技有限公司(DJI-Innovations,简称 DJI),成立于 2006 年,是全球领先的无人飞行器控制系统及无人机解决方案的研发和生产商,客户遍布全球 100 多个国家。通过持续的创新,大疆致力于为无人机工业、行业用户以及专业航拍应用提供性能最强、体验最佳的革命性智能飞控产品和解决方案。

    2 引用 • 14 回帖
  • Python

    Python 是一种面向对象、直译式电脑编程语言,具有近二十年的发展历史,成熟且稳定。它包含了一组完善而且容易理解的标准库,能够轻松完成很多常见的任务。它的语法简捷和清晰,尽量使用无异义的英语单词,与其它大多数程序设计语言使用大括号不一样,它使用缩进来定义语句块。

    543 引用 • 672 回帖 • 1 关注
  • OAuth

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

    36 引用 • 103 回帖 • 9 关注
  • CentOS

    CentOS(Community Enterprise Operating System)是 Linux 发行版之一,它是来自于 Red Hat Enterprise Linux 依照开放源代码规定释出的源代码所编译而成。由于出自同样的源代码,因此有些要求高度稳定的服务器以 CentOS 替代商业版的 Red Hat Enterprise Linux 使用。两者的不同在于 CentOS 并不包含封闭源代码软件。

    238 引用 • 224 回帖
  • Vue.js

    Vue.js(读音 /vju ː/,类似于 view)是一个构建数据驱动的 Web 界面库。Vue.js 的目标是通过尽可能简单的 API 实现响应的数据绑定和组合的视图组件。

    266 引用 • 665 回帖
  • SOHO

    为成为自由职业者在家办公而努力吧!

    7 引用 • 55 回帖 • 19 关注
  • Hadoop

    Hadoop 是由 Apache 基金会所开发的一个分布式系统基础架构。用户可以在不了解分布式底层细节的情况下,开发分布式程序。充分利用集群的威力进行高速运算和存储。

    86 引用 • 122 回帖 • 625 关注
  • TGIF

    Thank God It's Friday! 感谢老天,总算到星期五啦!

    287 引用 • 4484 回帖 • 669 关注
  • NGINX

    NGINX 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 NGINX 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本 0.1.0 发布于 2004 年 10 月 4 日。

    311 引用 • 546 回帖
  • JRebel

    JRebel 是一款 Java 虚拟机插件,它使得 Java 程序员能在不进行重部署的情况下,即时看到代码的改变对一个应用程序带来的影响。

    26 引用 • 78 回帖 • 664 关注
  • Caddy

    Caddy 是一款默认自动启用 HTTPS 的 HTTP/2 Web 服务器。

    12 引用 • 54 回帖 • 165 关注
  • Dubbo

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

    60 引用 • 82 回帖 • 595 关注