MiraiForum

    • 注册
    • 登录
    • 搜索
    • 热门
    • 最新
    • 未解决
    • 标签
    • 群组
    • 友情链接
    1. 主页
    2. han1549302096
    H
    • 资料
    • 关注 0
    • 粉丝 0
    • 主题 0
    • 帖子 6
    • 最佳 0
    • 有争议的 0
    • 群组 0

    han1549302096

    @han1549302096

    0
    声望
    1
    资料浏览
    6
    帖子
    0
    粉丝
    0
    关注
    注册时间 最后登录

    han1549302096 取消关注 关注

    han1549302096 发布的最新帖子

    • RE: 腾讯官方Bot接口扫盲

      @Dituon 刚刚在频道里测试成功了,QQ群应该是不好使

      发布在 开发交流
      H
      han1549302096
    • RE: 腾讯官方Bot接口扫盲

      @Dituon json是正常的,我看文档只有旧版api文档里出现过formdata方法传送图片,我不知道是我方法不对还是现在不接受formdata格式了。

      发布在 开发交流
      H
      han1549302096
    • RE: 腾讯官方Bot接口扫盲

      @Dituon 大概是这样的,只是发送了一个字符串

      const url = `https://api.sgroup.qq.com/v2/groups/${groupOpenid}/messages`;
              // const body = {
              //     content: replyContent,
              //     msg_type: 0,
              //     msg_id: msgid,
              // };
              // 创建一个 FormData 对象并添加字段
              const formData = new FormData();
              formData.append('content', 'hello');
              formData.append('msg_type', '0');
              formData.append('msg_id', msgid);
      
      
              try {
                  const response = await fetch(url, {
                      method: 'POST',
                      headers: {
                          // 'Content-Type': 'application/json',
                          'Authorization': `QQBot ${this.accessToken}`,
                          'X-Union-Appid': `${this.appId}`,
                      },
                      body: formData,
                      // body: JSON.stringify(body),
                  });
      
      发布在 开发交流
      H
      han1549302096
    • RE: 腾讯官方Bot接口扫盲

      @Dituon 是文本

      发布在 开发交流
      H
      han1549302096
    • RE: 腾讯官方Bot接口扫盲

      @Dituon 我后来删除了content-type,但仍然报错
      Error: Error: 304061 - invalid content
      at QQBot.replyToGroupMessage (c:\koshi_dev\koishi-app\external\handstwiki3\src\test111.ts:142:27)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

      发布在 开发交流
      H
      han1549302096
    • RE: 腾讯官方Bot接口扫盲

      @Dituon 是不是不支持formdata,我是这样写的,但是报错了

      const url = `https://api.sgroup.qq.com/v2/groups/${groupOpenid}/messages`;
              // const body = {
              //     content: replyContent,
              //     msg_type: 0,
              //     msg_id: msgid,
              // };
              // 创建一个 FormData 对象并添加字段
              const formData = new FormData();
              formData.append('content', replyContent);
              formData.append('msg_type', '0');
              formData.append('msg_id', msgid);
      
      
              try {
                  const response = await fetch(url, {
                      method: 'POST',
                      headers: {
                          'Content-Type': 'application/json',
                          'Authorization': `QQBot ${this.accessToken}`,
                          'X-Union-Appid': `${this.appId}`,
                      },
                      body: formData,
                      // body: JSON.stringify(body),
                  });
      

      报错

      Error: Error: 40011000 - 请求数据异常
          at QQBot.replyToGroupMessage (c:\test111.ts:145:27)
          at processTicksAndRejections (node:internal/process/task_queues:95:5)
      
      发布在 开发交流
      H
      han1549302096