<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                **主企業號主動發送消息,也就是企業號主動推送的消息,適合于企業的通知,通告等。因此如果公司有通知,要求通知到所有員工,就應該使用主動發送消息。** 格式是json格式,而且微信很靈活,當touser,toparty,totag的json值是null時,微信服務器主動忽略了。原來還擔心,如果是null,在生成json格式時如何忽略掉是null的字段。 核心基本類: ~~~ public class MsgBase { public MsgBase() { this.safe = "0"; //表示是否是保密消息,0表示否,1表示是,默認0 } /// <summary> /// UserID列表(消息接收者,多個接收者用‘|’分隔)。特殊情況:指定為@all,則向關注該企業應用的全部成員發送 /// </summary> public string touser { get; set; } /// <summary> /// PartyID列表,多個接受者用‘|’分隔。當touser為@all時忽略本參數 /// </summary> public string toparty { get; set; } /// <summary> /// TagID列表,多個接受者用‘|’分隔。當touser為@all時忽略本參數 /// </summary> public string totag { get; set; } /// <summary> /// 消息類型 /// </summary> public string msgtype { get; set; } /// <summary> /// 企業應用的id,整型。可在應用的設置頁面查看 /// </summary> public int agentid { get; set; } /// <summary> /// 表示是否是保密消息,0表示否,1表示是,默認0 /// </summary> public string safe { get; set; } } ~~~ ~~~ public static class MsgType { public enum MsgBaseEnum { Text = 1, image = 2, voice = 3, video = 4, file = 5, news = 6, mpnews =7 }; public static string GetMsgTypeText(MsgBaseEnum type) { string text = ""; switch(type) { case MsgBaseEnum.Text: text = "text"; break; case MsgBaseEnum.image: text = "image"; break; case MsgBaseEnum.voice: text = "voice"; break; case MsgBaseEnum.video: text = "video"; break; case MsgBaseEnum.file: text = "file"; break; case MsgBaseEnum.news: text = "news"; break; case MsgBaseEnum.mpnews: text = "mpnews"; break; default: throw new Exception("type=" + type + ",此類型的消息沒有實現"); } return text; } } ~~~ 文字類型的消息 ~~~ public class TextMsg : MsgBase { public TextMsg(string content) { this.text = new TextMsgContent(content); this.msgtype = MsgType.GetMsgTypeText(MsgType.MsgBaseEnum.Text); } public TextMsgContent text { get; set; } } public class TextMsgContent { public TextMsgContent(string content) { this.content = content; } public string content { get; set; } } ~~~ 發送消息 ~~~ public static class BLLMsg { public static bool SendMessage(MsgBase data) { string urlFormat = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={0}"; string accessToken = BLLAccessToken.GetAccessToken(); var url = string.Format(urlFormat, accessToken); WebUtils ut = new WebUtils(); var postData = Tools.ToJsonString<MsgBase>(data); //數據不用加密發送 LogInfo.Info("發送消息: " + postData); string sendResult = ut.DoPost(url, postData); SendMsgResult tempAccessTokenjson = Tools.JsonStringToObj<SendMsgResult>(sendResult); if (tempAccessTokenjson.HasError()) { LogInfo.Error("發送消息錯誤: " + Tools.ToJsonString<SendMsgResult>(tempAccessTokenjson)); return false; } return true; } } ~~~ 測試代碼: ~~~ private void button9_Click(object sender, EventArgs e) { TextMsg data = new TextMsg("測試發送文字消息給整個企業" + DateTime.Now); data.agentid = 7; data.safe = "0"; data.toparty = "1"; BLLMsg.SendMessage(data); } private void button11_Click(object sender, EventArgs e) { TextMsg data = new TextMsg("測試發送文字消息給醫療部" + DateTime.Now); data.agentid = 7; data.safe = "0"; data.toparty = "2"; BLLMsg.SendMessage(data); } private void button10_Click(object sender, EventArgs e) { TextMsg data = new TextMsg("測試發送文字消息給所有用戶" + DateTime.Now); data.agentid = 7; data.safe = "0"; data.touser = "@all"; BLLMsg.SendMessage(data); } private void button1_Click(object sender, EventArgs e) { TextMsg data = new TextMsg("單用戶文字消息" + DateTime.Now); data.agentid = 7; data.safe = "0"; data.touser = "iaodong"; BLLMsg.SendMessage(data); } ~~~ [主動發送消息官方文檔](http://qydev.weixin.qq.com/wiki/index.php?title=%E5%8F%91%E9%80%81%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看