知方号

知方号

chatgpt给出的企业微信接口为什么文档上找不到?

chatgpt给出的企业微信接口为什么文档上找不到?

url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/receive?key=" + token

看起来cgi-bin/webhook/receive像是个机器人的接口 ,但是文档上没有  是弃用了嘛  如果还再用 有相关文档吗?

下边贴出chatgpt 给出的代码示例:

/**

监听消息的方法

     */

    private static void ListenMessage(string accessToken, string token, int agentId)

    {

      // 循环请求接口

      while (true)

      {

        string url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/receive?key=" + token;

         

        try

        {

          HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

          request.Method = "POST";

          request.ContentType = "application/json";

          request.Headers.Add("Authorization", "Bearer " + accessToken);

           

          using (var streamWriter = new StreamWriter(request.GetRequestStream()))

          {

            string payload = "{"msgtype": "text", "agentid": "" + agentId.ToString() +

              "","text":{"content":"Hello, World!"}}";

            streamWriter.Write(payload);

            streamWriter.Flush();

            streamWriter.Close();

          }

           

          HttpWebResponse response = (HttpWebResponse)request.GetResponse();

          StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);

          string result = reader.ReadToEnd();

          reader.Close();

          response.Close();

          Console.WriteLine(result);

        }

        catch (Exception ex)

        {

          Console.WriteLine("Exception: " + ex.Message);

        }

         

        // 请求间隔时间 (建议在>=1秒内)

        Thread.Sleep(1000);

      }

    }

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至lizi9903@foxmail.com举报,一经查实,本站将立刻删除。