In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to use Enterprise account to send messages such as text, pictures, files, voice, video, picture and text messages". The content is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "how to use the Enterprise account to send messages such as text, pictures, files, voice, video, and picture and text messages."
1. The characteristics of Enterprise.
For the Enterprise, it has the following characteristics:
1) focus on more security
-only members of the enterprise address book can pay attention to various features such as enterprise ID, hierarchical administrator, confidential messages, and so on, to ensure the security of internal information in the enterprise.
The enterprise can set up itself to verify the identity of the follower and carry out the second security verification to ensure the security of the use and transmission of enterprise information.
If an employee leaves, the enterprise administrator can delete the member in the address book, the member automatically cancels attention to the enterprise account, and the history of the enterprise account in Wechat is also cleared.
2) Application configurable
-the enterprise can configure multiple service numbers in the enterprise account, and can connect different enterprise application systems. Only authorized enterprise members can use the corresponding service numbers.
3) there are no restrictions on messages
-No restrictions on sending messages, and provide comprehensive management interfaces and native capabilities of Wechat to adapt to complex and personalized application scenarios of enterprises.
Enterprises can take the initiative to send messages to employees, and the amount of messages is unlimited.
4) more convenient to use
-Enterprise account has a unified message entry in Wechat, which makes it more convenient for users to manage Enterprise account messages. The Wechat address book also provides direct access to applications in the enterprise account.
2. The content of the management interface of the enterprise account
At present, the contents of Enterprise account can be displayed in the following hierarchical diagram, including material management, passive response messages, address book management, custom menu and so on. For more information, please see the figure below.
3. Handling of Enterprise messages and events
Like the official account, the enterprise account can be divided into message processing and event handling. Here are their two types of processing operations. The messages sent are text messages, picture messages, file messages, video messages, voice messages, geographic text messages, graphics and text, multimedia messages and so on.
Event handling is mainly focused on and unfocused on events, as well as menu click type and view type operations, as well as geographical location reported events and so on.
The two types of processing diagrams are shown below.
4. Message management of Enterprise account
In the management background of the enterprise, like the official account, you can see the corresponding information exchange records, including text, pictures, geographical location, and so on, as shown below.
Because messages are divided into several types, including text (Text), picture (Image), file (File), voice (Voice), video (Video), picture and text message (News), MpNews and so on.
Therefore, we need to define and encapsulate them respectively, and the following is their information object design diagram.
The official definition of a message sent by the Enterprise is as follows:
Enterprises can take the initiative to send messages to employees, and the amount of messages is unlimited.
When calling the interface, the Https protocol and JSON packet format are used, and the packet does not need to be encrypted.
Currently, text, picture, voice, video, file, picture and text and other message types are supported. Except for the news type, other types of messages can be sent with a secrecy option, which is watermarked and can only be read by the recipient.
Let's take the text message sent as an example, which is defined as follows.
Text message
{"touser": "UserID1 | UserID2 | UserID3", "toparty": "PartyID1 | PartyID2", "totag": "TagID1 | TagID2", "msgtype": "text", "agentid": "1", "text": {"content": "Holiday Request For Pony (http://www.php.cn/)"}," safe ":" 0 "} parameter must indicate whether touser is UserID list (message recipient) Multiple recipients are separated by'|'. Special case: if @ all is specified, a toparty No PartyID list is sent to all members who follow the enterprise application, and multiple recipients are separated by'|'. When touser is @ all, this parameter totag No TagID list is ignored, and multiple recipients are separated by'|'. When touser is @ all, it is ignored that this parameter msgtype is the message type. In this case, it is fixed as: textagentid is the id of enterprise applications, integer. You can check whether content is a message content on the settings page of the application. Whether safe indicates whether it is a confidential message. 0 means no. 1 means yes. Default is 0.
Each of these messages contains the following messages, which are their common properties:
Touser ":" UserID1 | UserID2 | UserID3 "," toparty ":" PartyID1 | PartyID2 "," totag ":" TagID1 | TagID2 "," msgtype ":" text "," agentid ":" 1 "
So we can define a base class to facilitate the hosting of this common information.
/ Enterprise sends the basic message content of the message / public class CorpSendBase {/ UserID list (message receivers, multiple receivers are separated by'|'). Special case: if @ all is specified, a list of / public string touser {get; set;} / PartyID is sent to all members following the enterprise application, and multiple recipients are separated by'|'. Ignore this parameter / public string toparty {get; set;} / TagID list when touser is @ all, and multiple recipients are separated by'|'. Ignore this parameter / public string totag {get; set;} / public string msgtype {get; set;} / id of enterprise applications when @ all is the parameter / message type / enterprise application id, integer. You can view / public string agentid {get; set;} / indicates whether it is a confidential message on the settings page of the application. 0 means no, 1 means yes, and the default is 0 / / [JsonProperty (NullValueHandling = NullValueHandling.Ignore)] public string safe {get; set;}}.
Other messages can then inherit this base class one by one, as shown below.
It will eventually form the following inheritance diagram.
5. Definition and implementation of message interface
Once the relevant sending object is defined, we can define its unified sending interface, as shown below.
/ Enterprise message management interface defines / public interface ICorpMessageApi {/ sends messages. / / the administrator needs to have permission to use the application and view the recipient touser, toparty and totag, otherwise the call will fail. / / CommonResult SendMessage (string accessToken, CorpSendBase data);}
Finally, messages of types such as text are implemented according to the interface definition, and the implementation code is as follows. Note that the sending process does not need to call the encryption class for encryption.
/ Enterprise message management implementation class / public class CorpMessageApi: ICorpMessageApi {/ send messages. / / the administrator needs to have permission to use the application and view the recipient touser, toparty and totag, otherwise the call will fail. / / public CommonResult SendMessage (string accessToken, CorpSendBase data) {CommonResult result = new CommonResult (); string urlFormat = "http://www.php.cn/{0}"; var url = string.Format (urlFormat, accessToken); var postData = data.ToJson () / / send CorpSendResult sendResult = CorpJsonHelper.ConvertJson (url, postData) without encryption; if (sendResult! = null) {result.Success = (sendResult.errcode = = CorpReturnCode. Result.ErrorMessage = string.Format ("invaliduser: {0}, invalidparty: {1}, invalidtag: {2}", sendResult.invaliduser, sendResult.invalidparty, sendResult.invalidtag);} return result;}} 6, message sending operation and actual effect
After defining the corresponding sending object, we can carry out unified message sending operation, including text, picture, file, voice and other types of messages. Note that some messages need to be uploaded to the server and then sent out according to mediaId.
The action code for sending text and pictures is as follows.
Private void btnSendText_Click (object sender, EventArgs e) {/ / send text content ICorpMessageApi bll = new CorpMessageApi (); CorpSendText text = new CorpSendText ("API Chinese Test (http://www.php.cn/)"); text.touser =" wuhuacong "; text.toparty =" 4 "; / / Department ID text.totag =" 0 " Text.safe = "0"; text.agentid = "0"; CommonResult result = bll.SendMessage (token, text); if (result! = null) {Console.WriteLine ("send message: {0} {1} {2}", text.text.content, (result.Success? "success": "failure"), result.ErrorMessage);}} private void btnSendImage_Click (object sender, EventArgs e) {btnUpload_Click (sender, e); if (! string.IsNullOrEmpty (image_mediaId)) {/ / send picture content ICorpMessageApi bll = new CorpMessageApi () CorpSendImage image = new CorpSendImage (image_mediaId); CommonResult result = bll.SendMessage (token, image); if (result! = null) {Console.WriteLine ("send picture message: {0} {1} {2}", image_mediaId, (result.Success? "success": "failure"), result.ErrorMessage)} above are all the contents of this article entitled "how to use Enterprise account to send text, picture, file, voice, video, picture and text messages, etc." Thank you for your reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.