收藏
回答

按文档调用,返回错误码43002, errmsg 为:require POST method

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug 智能接口 微信iOS客户端 8.0.49 1.9

https://developers.weixin.qq.com/doc/offiaccount/Intelligent_Interface/AI_Open_API.html

发送的是 POST 请求,但响应信息为:{"data":{"errcode":43002,"errmsg":"require POST method hint: [dAEevA07172801] rid: 662fb1b5-3b7b9004-4d6d046f"},"header":{"Connection":"keep-alive","Content-Type":"text/plain","Date":"Mon, 29 Apr 2024 14:41:57 GMT","Content-Length":"103"},"statusCode":200,"cookies":[],"accelerateType":"none","errMsg":"request:ok"}。 错误信息与实际情况对不上,请给出详细的调用 demo。

function getSttContent(audioPath: string, accessToken: string): string {
  wx.request({
    url: `http://api.weixin.qq.com/cgi-bin/media/voice/addvoicetorecofortext?access_token=${accessToken}&format=&voice_id=${audioPath}&lang=zh_CN`,
    method: 'POST',
    success: (res) => {
      console.log('data: %s', JSON.stringify(res))
      // const data = res.data.data
      
      // if (data.errcode !== '0') {
      //   return;
      // }


      setTimeout(function() {
        wx.request({
          url: `http://api.weixin.qq.com/cgi-bin/media/voice/queryrecoresultfortext?access_token=${accessToken}&voice_id=${audioPath}&lang=zh_CN`,
          method: 'POST',
          success: function(res) {
            // 第二个接口请求成功的处理逻辑
            console.log("stt 结果: %s", JSON.stringify(res))
          },
          fail: function(error) {
            // 第二个接口请求失败的处理逻辑
          }
        });
      }, 3000); // 等待3秒
    }
  })


  return ""
}
回答关注问题邀请回答
收藏

3 个回答

  • 社区技术运营专员--许涛
    社区技术运营专员--许涛
    04-30

    你好,麻烦使用https

    04-30
    有用
    回复
  • hello world
    hello world
    04-30

    这些接口建议服务端调用,前端理论上不感知access_token

    04-30
    有用
    回复
  • Mr.Zhao
    Mr.Zhao
    发表于小程序端
    04-29

    用https

    04-29
    有用
    回复
登录 后发表内容