I have been curious about short links before, but RECENTLY I researched them and found that they are quite fun. This article is just a simple technical explanation, technology is not good or bad, only to see how the use of people to master.

1. What are short links

A Short URL, or Short URL, may also be called a Short link or Short URL, is an intermediate link that a Short URL server generates for a link. A short link is not necessarily shorter than the original link.

2. The overall idea

  • As a first step, need a registration service, long link with short links will be request times, 100000 times a day after more than will be banned, specific to generate short links See WeChat documentation (developers.weixin.qq.com/doc/offiacc…
  • The second step, the need for a proxy pool (there are many online proxy pools, recommended sun proxy pool is good), (to prevent the number of switching, the level of domain name export is sealed)
  • The third step is to generate a short link back based on the broker pool for promotion
  • 4, real-time monitoring, write a scheduled task, once a minute is enough, if blocked, continue to execute the second step (real-time monitoring, recommend write a scheduled task, the scheduled task can use qutraz, and then push recommend write a MQ to push, so that you can push more than one)
  • The fifth step someone may ask what is banned, how to simulate banned, test banned. HTTP requests through Java can take the parameters in the head without redirection. As long as the head header contains “110. Weixin” or “support.weixin”, it proves that your domain name is banned by wechat
  • At the end of step 6, all of the above is simply implemented in the following code. The scheduled task depends on its implementation. Schedule can also be used, as long as it is unique

3. Specific implementation (code added on Sunday, you can also directly leave a message below)

  • The proxy implementation

Copy the code

Those of us who are quarrying stone, let us have the vision of a cathedral!