Say ByeBye👋 to the ETA features in my WeChat miniprogram

Background

Last year, I have released a WeChat miniprogram which is an alternative to the KMB 1933 APP.

Why I still spent my still developing a mini-program? I have below pain points when using the KMB APP, the points were based on the KMB 1933 app version released around min-2019.

  1. The full-screen ads keep popping up on my iPhone.
  2. The app was so slow to open and crash occasionally.
  3. I just care about some bug routes and stops, don’t give me too much info I don’t need.

My solution

My miniprogram have these three key features to solve the pain point:

  1. Home screen: Show ETA of the bookmarked bus stops(Swipe left to delete the bookmark).
  2. Second screen: Show nearby stops ETA (Swipe left the row to bookmark the stop).
  3. Third screen: Search bus routes(announce, schedule, and map views of the routes)
miniprogram screenshots

Welcome to have a trial by scan this QRCode by WeChat:

The miniprogram QR Code

The ETA features

EAT(Estimated Arrival Time) is the key info of the app. There’re two ways we can try to get the ETA info:

  1. KMB official Web site: https://search.kmb.hk/KMBWebSite/index.aspx?lang=tc
  2. KMB 1933 APP

My miniprogram is using the KMB official Website as the data source.

KMB official website site ETA feature screenshoot.

KMB official Website ETA feature is a pure front-end function without any authentication. You can easily find out the js source code to inspect the logic of how it integrated with the API. I can tell you there’s not fanny encryption stuff.

However, the KMB official website has tried many ways to protect the API endpoint from abuse. The recent key improvement is that KMB introduced Google reCAPTCHA to protect the API.

The new captcha key for invoking the ETA API.

The captcha key will be generated when the user open the KMB website and bound with the KMB domain (I guess it will bind with the user IP as well). So I the captcha key one-off and can’t be reused.

I created a codesandbox demo to try the captcha.

https://codesandbox.io/embed/friendly-cartwright-dtp23?fontsize=14&hidenavigation=1&theme=dark

The sandbox site is using my own Google reCAPTCHA. If you replace with KMB key 6LdiOd8ZAAAAACukKcCRmmf_Ll2hgSIVya22YR99, you will get the error of “ERROR for site owner: Invalid domain for site key”.

Possible solutions

Since the KMB website is a pure front-end app, one possible solution is that we can simulate a browser in node.js runtime to get the google captcha token then invoke the ETA API. The headerless browser can be done by puppeteer or phantomjs.

To run a browser will be a huge overhead or it may require some daemon service to accelerate performance, so some serverless env such lambda or cloud function maybe not suitable to host this kind of service. (My miniprogram API is hosted by WeChat Cloud Function).

Another solution is to hack the KMB 1933 APP. For example, using some proxy apps such as Charles to monitor the APP traffic with backend API, hopefully, you can get the dedicated or more well-organized API of how the APP gets the ETA data.

Usually, the APP will use HTTPS protocol to secure communication. The good news is that Charles can use man-in-the-middle HTTPS proxy so that you’re able to view in plain text the communication between web browser and SSL web server. The bad news is that if the APP enables the HTTP Public Key Pinning (HPKP) the Charles will be useless for the proxy.

Thank you for reading.

《普希金》

本文旨在阐述严肃文学在流行音乐载体起到的大众传播效果。


听音乐也是会上瘾的。没得听音乐的感觉是这样,你可以问问烟鬼一天不抽烟是什么感觉。

最近在随机地听李志的各张live专辑,随机到了这首歌: 普希金 – 李志x丁薇丨live 2015 动静 https://www.youtube.com/watch?v=TXuLHJm9wsU

你听一听就感觉不一样,有种学院派的流行音乐风格,因为这是丁薇的歌。如果你对她熟悉,你可能听过她写的《女孩与四重奏》,早起是由歌手马格演唱。如果你对马格有点印象,可能你听过她的《远远的远,远远》。。。不过马格已经一早淡出了娱乐圈,在那个90年代,马格可能也是和一些乐队一样(我这里想说的是鲍家街43号),生存所迫,无奈解散或改行。


我应该要回到标题,有点离题了。

《普希金》这首歌是有点特别的,感觉像个钩子,你在100首歌里面随机到它,就会停下来,谷歌搜索一下看看发生什么情况。(这篇文章的诞生就是发生的情况之一。)

排除了这首歌旋律对我的吸引,起码我觉得,标题让这首歌加分不少。

歌词第一句:假如你不在我身边。。。

这难道不就是《假如生活欺骗了我》吗?

当然我还发现了一些来自普希金有趣的句子(以下是浮躁时代的快速阅读方式【谷歌关键字:普希金 名言】):

  1. 讀書和學習是在別人思想和知識的幫助下,建立起自己的思想和知識。 (多么好的勉励自己读书的理由)
  2. 读书是最好的学习,追随伟大人物的思想,是富有趣味的事情。(多么好的解析为什么读书的理由)
  3. 世界的設計創造應以人為中心,而不是以謀取金錢,人並非以金錢為對象而生活,人的對象往往是人。(多么好的指导产品设计的理由)(在各种IT新品发布会,引用这句话,格调马上上来了)
  4. 不管怎么说,不怀希望、不求报答的爱情肯定比一切工于心计的引诱更能打动一个女人的心。(多么好的打动女孩子的理由)
  5. 沒有幸福,只有自由和平靜。(多么好的让自己接受平庸平凡的理由)

你看伟大文豪普希金就被我几句话说完了。

完。