Write in front

In the last tweet, "Programmer's Romantic Realization: A Tutorial to Remind Ta of Babysitter by Pushing Messages Every Day", we introduced the way of WeChat test number to push messages, but there are the following problems that we don't like:

  1. The title of the test number cannot be modified to a user-defined name, and the test number's avatar cannot be modified
  2. The pushed message can only be received by clicking the subscription number. After clicking the subscription number, the message will be sent from the list
  3. You must customize the template every time you want to modify the content
  4. The official of Tencent, the WeChat test account, made a clear announcement that this channel would be closed, which may lead to unavailability at any time
  5. Many tests do not report errors, but the push fails. Most of the reasons are inferred to be the unstable test number

In response to the above problems, the online tycoons have upgraded the version by means of enterprise WeChat applications to solve the above headache. I would like to thank the online tycoons for their contributions to this, and hereby declare that every word and sentence of this tutorial is manually typed by the blogger, and all the code comes from open source projects, so don't spray it if you don't like.

Terminology

In order to focus on the computer Xiaobai, we will first make a parameter for the name mentioned later. We hope you can have an impression to facilitate the troubleshooting of later problems.

  • Enterprise WeChat is not only applicable to enterprises, but also to individuals , but some functions are restricted without authentication, which does not affect the use of this tutorial.
  • Hefeng weather platform, which is a third-party platform for obtaining weather forecast, we register this platform and Real name authentication After that, you can get the weather forecast data for free, but there is a limit on the number of weather forecast data every day, which is subject to the official. If it is an individual who pushes news every day, it is enough.
  • Enterprise application: after registering enterprise WeChat, we can create an enterprise application, and then push messages through this application. You can simply understand that the enterprise WeChat application here ≈ WeChat official account
  • Enterprise trusted IP: Full name enterprise trusted IP address. To ensure the security of enterprise applications, Tencent has set the enterprise trusted IP address. Only the address added to the enterprise trusted IP can use the program to push messages.

Effect Preview

 Very popular enterprise WeChat daily push super detailed nanny class tutorial

Tutorial Steps

The tutorial is divided into 8 steps: it is no problem to follow the steps. If you don't understand, watch more videos and operate more tutorials.

1. Registered enterprise WeChat

Browsers open enterprise WeChat web pages( https://work.weixin.qq.com/ )->Click the home page to register now

 Very popular enterprise WeChat daily push super detailed nanny class tutorial

2. Log in to the enterprise WeChat background

The same browser opens the enterprise WeChat page( https://work.weixin.qq.com/ )->Log in to the enterprise WeChat background directly with the bound administrator WeChat scanning code.

Click the upper right corner in turn My Enterprise ->Find Enterprise Id -> Remember this value we will use later

3. Create message push application

Find in the navigation bar Application management -> Create app

 Very popular enterprise WeChat daily push super detailed nanny class tutorial

Upload the application logo and fill in the application name, that is, the avatar and name of the application, In the visible range, click to select the entire enterprise.

 Very popular enterprise WeChat daily push super detailed nanny class tutorial

After creation, enter the application and find AgentId Save it, we need it later. Secret Click View. In the pop-up box, you need to click Send to Enterprise WeChat Mobile Phone - Enterprise WeChat Team to view, receive and save it, and I also need it later.

4. Fill in the enterprise trusted IP

Drop down to the bottom, find the developer interface ->enterprise trusted IP ->click configuration ->fill in the IP address and confirm

Note: Enter the IP address of the environment where your program will operate in the pop-up box, for example:

  • For example, if I use my own computer to run the push program, I need to fill in the IP results in Baidu directly, or click the link to query the IP directly( Click this query IP
  • For example, if I want to use ECS to run push programs, I need to fill in the IP address of the server

In order to meet the needs of most people without ECS, I will use the local machine to run push tutorials to see my operations.

 Very popular enterprise WeChat daily push super detailed nanny class tutorial

5. Application and Wind Weather Key

As mentioned earlier, to obtain the weather, you must register with the Wind Weather platform account to obtain the key, which we need to fill in later.

  1. Open the Peace Weather Official https://id.qweather.com/#/login , it is recommended to directly use WeChat login to register
  2. After the first registration is completed, the mobile phone number and email address should be bound as required, otherwise the KEY cannot be applied. After completing the above steps, find and click Account settings for more Hefeng products -> Hefeng Weather Developer Console

     Very popular enterprise WeChat daily push super detailed nanny class tutorial

  3. Click Application Management on the left ->Create Application ->Free Developer Edition ->Enter Application Name ->Web API ->Enter KEY Name ->Complete Creation, Find the value of KEY to record, and we will use it later

6. Configurator Parameters

Follow my WeChat official account "On Code Efficiency", and then reply to "WeChat Romance 2022" in the small window to download the package. After downloading, unzip and open config.py , fill in the parameters saved by the preconditions above in turn, and adjust the template for other contents according to the comments.

Where wxid, agentid, secret, qweather are required fields: the meanings of the parameters are as follows:

"Wxid": the enterprise WeChat ID we obtained by logging in the enterprise WeChat in the second step

"Agent id": the agent id obtained from the enterprise WeChat application we applied for in the previous step 3

"Secret": the secret obtained from the enterprise WeChat application we applied for in the previous step 3

"Qweather": the key of moderate wind weather we applied for in step 5 above

 SYS_CONFIG = { #Enterprise WeChat Enterprise ID, required application address: https://work.weixin.qq.com/ "wxid": "", #Enterprise WeChat application AgentId, required "agentid": "", #Enterprise WeChat application Secret, required "secret": "", #Hefeng Weather Key, not required application address: https://id.qweather.com/#/login "qweather": "", #Weather forecast address, not required #Format: city city/county/district, multiple addresses are separated by&& #For example, Chengdu Shuangliu&Chengdu Wuhou "City": "Chengdu Wuhou", #Anniversary name, not required #Recurring days, which occur every year. Multiple dates are separated by&& #For example, the birthday of a formal girlfriend&the birthday of a junior "Targetname": "The birthday of an official girlfriend&the birthday of a mistress", #Anniversary date, not required #Gregorian calendar format 20XX-XX-XX, add n before the lunar year #Multiple dates are separated by&&. Note that they correspond to the targetname name #For example: 2022-08-10&&n2021-08-15 "targetday": "2022-08-10&&n2021-08-15", #Single day project name, not required #Days that only occur once, only days in a certain year, and multiple dates are separated by&& #For example: meet with the mistress "Beginname": "Meet", #Single day date, not required #Gregorian calendar format 20XX-XX-XX, add n before the lunar year #Multiple dates are separated by&&. Note that they correspond to the beginname name #For example: 2022-08-15&&n2022-12-10 "beginday": "n2022-12-10", #Image text type, not required #1 refers to single image and text, 2 refers to multiple images and text, and the default is single image and text "msgtype": "1" }

7. Run program

Run the program for the first time according to the following steps:

 pip install -r requirements.txt -i  https://pypi.tuna.tsinghua.edu.cn/simple   python send.py

8. Configure mobile WeChat to receive messages

If the above steps are all right, then at this moment you can directly invite Ta to enter the enterprise WeChat, and then bind personal WeChat to receive the message push in the personal WeChat. There is no need to download the enterprise WeChat. The operation steps are as follows:

  1. Send the QR code of invitation to follow to TA, scan the mobile WeChat code to follow, and you will be prompted "click to verify your identity and join XXXX". After verification, you can receive the follow-up message.
  2. Enterprise WeChat background - My enterprise - WeChat plug-in , WeChat plug-in logo can be customized, that is, you can see the enterprise's image from WeChat
  3. Find the QR code inviting attention, scan the code with personal WeChat, and set Allow members to receive and reply to chat messages in WeChat plug-ins tick

     Very popular enterprise WeChat daily push super detailed nanny class tutorial

  4. The enterprise WeChat mobile terminal finds ->Settings ->New message notification ->Receive messages only in enterprise WeChat ->Uncheck all ->Finish
  5. You can receive push messages on WeChat without accident

receive information

All the required documents and detailed text tutorials of this tutorial are placed on my WeChat official account "On Code Efficiency". After following, you can get all the resources by replying to "WeChat Romance 2022" in the small window. Thank you for your support.

common problem

1、“No module named requests”?

Answer: When executing the command, "No module named requests" appears, indicating that the function did not find the dependency. Execute the installation dependency command first.

2. "Failed to obtain enterprise WeChat access_token"?

Answer: Please check whether the wxId, agentid and secret parameters are filled in correctly, and pay attention to the punctuation in both Chinese and English formats.

3. Did you not find XX/failed to obtain XXID?

Answer: Please check whether the city filling format meets the requirements. The format is city city/district/county. Do not carry suffixes such as city/district/county, such as Chengdu Wuhou. Check and windy weather qweather Whether it is filled in correctly and whether there are extra space characters.

4. Other errors?

Answer: Please check whether the configuration information is filled in correctly, including the spelling of the name (key), the format of the content (value), the value, and whether there are extra spaces.

If the problem cannot be solved, please download the latest package and try again according to the tutorial.

If it still can't be solved, please follow the WeChat public account [efficiency on code] chat box to reply to the keyword "WeChat Romance 2022" for group feedback if it can't be solved repeatedly

5. How to modify a template?

Answer: Refer to the configuration file config.py Modify the content and date.

6. Some contents are not fully displayed?

A: Due to the limitation of Tencent's WeChat application API, the text exceeding the word limit will be automatically truncated and not displayed. The image and text display page is not subject to this restriction, but is still limited by the length of the image link and the length of the text. Please properly adjust the weather in multiple regions, multi date reminders and other contents.

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.

 Very popular enterprise WeChat daily push super detailed nanny class tutorial

The code is efficient, a public account with many interesting black technologies, follow me, and continue to share more high-quality resources for you!

Disclaimer: All software, tutorials and content information provided by this public account are only for learning and research purposes; The above contents shall not be used for commercial or illegal purposes, otherwise, the user shall bear all consequences. The information of this public account is collected and collated from the network, and the copyright dispute has nothing to do with this public account. You must completely delete the above content from your computer or phone within 24 hours after downloading. If you like the program and content, please support the genuine, purchase and register, and get better genuine services. We attach great importance to copyright issues. If there is any infringement, please contact us in the public account window. Please understand!