Write in front

A few days ago, the little sweet potato platform flashed popular videos, and the programmer's boyfriend pushed her news regularly every day, including local weather conditions, how many days together, how many days before her birthday and other information. She was so happy that she sent the little sweet potato platform feeling very romantic. A lot of people in the comment area asked for the source code, so I looked at the following principles, In fact, Python wrote a script and used the WeChat test number platform to push messages. After all, this scheme does not need additional domain names and server resources, and it can be simply implemented. It is simply too difficult to run python programs for Xiaobai, so the simplest executable version of exe came. Today, a super complete tutorial is released to meet all friends in the comment area, Hurry to follow the tutorial!

Implementation effect preview

 Programmer's romantic realization: push messages to Ta regularly every day to remind the nanny of the super detailed tutorial

Step teaching

Preconditions:

  1. One Windows computer. It is recommended that win10 or above systems, and win7 systems may have some bugs
  2. A pair of industrious hands

1. Download program

Here we have prepared a complete executable program for you, Pay attention to my public account 'efficiency on code', and you can get it by replying to 'programmer's romantic push package' in the small window of the public account.

After downloading, you unzip to get the following two files:

 Programmer's romantic realization: push messages to Ta regularly every day to remind the nanny of the super detailed tutorial

explain:

1. Config.txt: the program configuration file to configure your own information, which will be described in detail in subsequent tutorials

2. Main.exe: executable program of program main entry

2. Apply for WeChat test number and parameters

  • Browser URL: https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login , open the WeChat public platform interface test account application platform, and scan WeChat to log in.
  • Remember the test number information after login: appID and appsecret , we will use
  • Pull down and open WeChat code scanning to follow the test number, and then refresh it. WeChat information will appear on the right, which needs to be pushed to several people. Remember this WeChat, and we will use it later
  • Find the template message interface and click Add Test Template. The template title is the title pushed from the public account. The template content can refer to the following: Remember the template ID after adding, and we will use it later

     {{date.DATA}}   City: {{city. DATA}} Weather: {{weather. DATA}} Minimum temperature: {{min_temperature. DATA}} Maximum temperature: {{max_temperature. DATA}} Today is the {{love_day. DATA}} day of our love {{birthday1. DATA}} days before the first girlfriend's birthday {{birthday2. DATA}} days before the second girlfriend's birthday {{birthday3. DATA}} days before the third girlfriend's birthday {{note_en.DATA}}   {{note_ch.DATA}}
  • Note: Please do not add or modify the information not mentioned on the page.

3. Modify configuration information

Open it with Notepad or notepad++text editing tool config.txt The default configuration file looks as follows:

 { #Public account configuration #The public account appId needs to be modified to the appID obtained in step 2 "app_id": "", #The public account appSecret needs to be modified to the appsecret obtained in step 2 "app_secret": "", #The template message ID needs to be modified to the template ID obtained after adding the template in step 2 "template_id": "", #If there are multiple WeChat signals receiving public account messages, they need to be separated by commas in [], such as ["wx1", "wx2"], and need to be modified to the WeChat signals obtained in step 2 "user": [""], #Information configuration #All cities in the province are shown in the appendix "Province": "Sichuan", #City "City": "Chengdu", #Birthday 1 corresponds to the content in the template file {{birthday1. DATA}} "birthday1": "1997-01-01", #Birthday 2 corresponds to the content in the template file {{birthday2. DATA}} "birthday2": "1999-12-01", #Birthday 3 corresponds to the content in the template file {{birthday3. DATA}} "birthday3": "1990-05-01", #Same format as above for the days together "love_date": "2022-04-05" }

Screenshots corresponding to each parameter are as follows:

 Programmer's romantic realization: push messages to Ta regularly every day to remind the nanny of the super detailed tutorial

4. Run program

ensure config.txt No problem, and keep and main.exe In the same directory, double-click directly to run main.exe A small black window pops up, prompting you to press any key to exit the prompt, and WeChat receives the message without accident. Note that this test number is in the subscription number, not the outermost, so you must enter the subscription number to see this message.

It's useless. Go to implement it for Ta~

5. Set daily scheduled push (optional)

This operation will not take effect until your computer is turned on at the push time.

  1. Search Box Search Task Scheduler
  2. Click on the right to create a new task with a name that describes customization
  3. Click Trigger to create a new trigger
  4. Define the time and frequency you want to execute, such as 8 o'clock every day. Check Enabled
  5. Click Operation to create a new operation
  6. Program or script selection main.exe The path, starting from the location where the directory is filled in
  7. Condition removal check (this task can only be started when the computer is using AC power)
  8. Set check (if the planned start time is over, start the task immediately)
  9. Automatic push when waiting for the set time

common problem

  1. Double click to run and report an error. This program cannot be started because api ms win core path 1-1-0.dll is missing from the computer?

    Answer: This error is that the computer lacks some components necessary for running, which usually appears on the win7 system. It is recommended to replace the computer or download the corresponding patch from Baidu before running.

  2. Double click the operation prompt Unhandled exception in script?

    A: Please check your config.txt For configuration files, all commas are in English, and don't add too many double quotes. The correct format for pushing multiple accounts is "user": ["11111111", "2222222", "3333333"],

  3. The running program did not report an error, but did not receive a message push?

    Answer: The message is displayed in the subscription number. If it is checked or not, please log out of the application test number again and log in again. Compare whether the appID and appSecret have changed. If they have changed, fill in and save again and try again.

  4. Can I change the name of the test number xxxx?

    Answer: No, only authenticated public accounts can be modified.

  5. Can you not push the last two lines of the message?

    Answer: Yes, you can only delete the last two lines of the template. That text changes every day, so you are not recommended to delete it.

Extended Reading

  1. How to set daily scheduled task push?

    Answer: There are many ways to implement it. Please implement it according to your own situation. 1. Add Windows planned task management; 2. Run in Python source code mode, and Linux provides crontab scheduled task operation; 3. Third party pagoda panel plan task realization; 4. The github action script can run regularly

  2. How to add regular water drinking reminder?

    A: Just add a new template and write the content. As long as you master the principle, please use your imagination in a fun way.

listen for

If you want to know about black technology, you can leave a message in the comment area, including but not limited to program related, computer skills, software resources, entertainment resources, etc.

 Programmer's romantic realization: push messages to Ta regularly every day to remind the nanny of the super detailed tutorial

Article Contents