当前位置:网站首页>Notes on enterprise wechat development [original]

Notes on enterprise wechat development [original]

2022-06-26 04:19:00 Telkobe

Link to the original text

Because the company needs , When someone submits a new task, it is necessary to timely notify the relevant personnel to handle it , However, the effect of messages on the site is not very ideal , People need to be in front of the computer to know whether there is a new task , Others are emails , SMS can also achieve the effect of similar notification , But if the news is more frequent, it doesn't feel appropriate , Therefore, it is finally considered to implement on wechat

At first, I wanted to push relevant messages through wechat official account , Later, I found that there was a time limit for customer service messages , It's usually 48 Within hours , If the user does not have necessary interaction with the official account during this period , that 48 After hours, the server cannot actively push the customer service message to the specified user . The template Message requirements are also very strict , Only official approved templates can be used , It's hard to find the perfect template for your business , And template messages should not be pushed too frequently , Official examples ( The sending frequency of template message cannot be too high to disturb the receiver example : A user clicks on the custom menu of the official account once or other triggering operations , The continuous received 3 Or more duplicate template messages , It's a violation ), Anyway, it is still a bit risky to push the template messages of official account as daily work messages , Maybe it will be banned one day . Finally, I found a good thing , Enterprise WeChat , Enterprise wechat has the same functions as official account , Push messages include , Web authorization, etc , So we quickly transplanted the relevant configurations of enterprise wechat to the previously developed official account code .

The core of the whole program is to use Easywechat, This thing is still very easy to use , Encapsulate some disgusting aspects of wechat development at ordinary times , Users basically only need to care about the business layer , Very efficient development . Here is a basic code ( Copy and paste official documents ).

 $config = [
    'corp_id' => 'xxxxxxxxxxxxxxxxx',
    'agent_id' => 100022,
    'secret'   => 'xxxxxxxxxx',
    // server config
    'token' => 'xxxxxxxxx',
    'aes_key' => 'xxxxxxxxxxxxxxxxxx',
    //...];
    $app = Factory::work($config);
    $app->server->push(function(){
    return 'Hello easywechat.';}
    );
    $response = $app->server->serve();$response->send();

This code consists of a simple enterprise wechat server

corp_id: Enterprise WeChat ID, Log in to the official website of enterprise wechat and click my enterprise , The bottom is .

agent_id: Self built application ID

secret: Self built application secret.

Self built applications are a core thing , It is responsible for pushing the following messages . Click on Application Management , Click Create Application in self build .

image.png

Set applied logo And name these , All custom , very nice

image.png

After the creation, you can get the application ID and secret 了 . Find the receiving message module , Set the message server configuration , It is similar to the server configuration of wechat official account , You need to set up your own server in advance , Submit the code to the server and then do this step , Because the configuration server url Wechat will check the address , If you access this url Failed to return the value to wechat server , Then it will prompt failure .

image.png

image.png

In this step, we get token and aes_key. Everything required for the configuration items in this code has been provided .

Click to the bottom of the application details to find these two things , Web page authorization and enterprise wechat authorization , Then configure the domain name , And the previous server configuration url Same domain name , This is mainly used for web page authorization to obtain user information .

image.png

That's all for the basic steps

原网站

版权声明
本文为[Telkobe]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180535384901.html