收藏
回答

同样的内容,使用 NodeJS 请求成功,在C#中使用 HttpClient 请求返回签名错误?

https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/intracity_service.html

现在的鄙视链都已经这么严重了嘛?同样签名,同样的请求头部,同样的参数。使用NodeJS 的 axios 请求库,可以正常返回。但是在C#中使用HttpClient 却显示签名错误。

为了验证正确性,我都怀疑是我这个写了多年C# 代码的程序员出现了问题,特意的使用 PostMan/ApiPost 进行了测试,断点将 NodeJS 发送的数据和请求头部,全部放入 PostMan/ApiPost 进行了发送请求测试。结果还是得到的这一串:

{"errcode":40234,"errmsg":"invalid signature rid: 653249ef-2760901b-3a1f8f59"}


OK,OK,OK,说到这里可能并不会有人相信我,现在我就来丢一串视频文件,并且附带两个请求的相关数据。

OK,OK,OK。除了腾讯视频,不支持我上传视频文件是吧???可以,我不上传了,考虑太多因素,本身是想上传服务器的,但是生产服务器,又不敢上传,所以,需要视频的,可以加我微信,我提供给你。

如果官方 需要视频,请及时联系我

微信号:F132951 微信名:小方

放一些参数把,这个是NodeJS 的参数(第一次发现问题保存的)


{
  status: 200,
  statusText: "OK",
  headers: {
    connection: "close",
    "content-type": "text/plain",
    date: "Wed, 18 Oct 2023 18:27:31 GMT",
    "wechatmp-appid": "appid",
    "wechatmp-timestamp": "1697653651",
    "wechatmp-serial": "8f60d9c2510d38f3ecaa3b2e8d3b0142",
    "wechatmp-signature": "foURexH30z6Vq09VmAczYSHYurdmuwDWLMeMgqKm7GlhWkUilS7+35BxIH+RdFHkdqHvmEm7ZPtuyOePyNxyCwnxKAjlNy7+ecKbNlugFEzW4gGjO5f/kL01yqkQeR5Z1UtAot+hADqhaaz+6jtX5CyqUGIGJtS0d+CyD89VnLVk/NjW/DF5J3xIchyHPhytOIiF6gbXCXvaGcu9km8W4fKZOaFfxGAVrHux6PwMVT4Q+j9+HJhunqMG+U2YZLCuLW5oYR7UfHZ9InvNNB3f76nPe64GxPXH81F8zgWqZMJXHBxNZAx2PC99/AEdVMlokoVb6Ij3d2j5cPF3WIYalw==",
    "content-length": "305",
  },
  config: {
    headers: {
      Accept: "application/json, text/plain, */*",
      "Content-Type": "application/json",
      "Wechatmp-Appid": "appid",
      "Wechatmp-TimeStamp": "1697653176",
      "Wechatmp-Signature": "5LK+EUZQPFu4mdxNMigcddkzy4kbBkZauiaHxqLuM58QCmrf3/EciyXteO3OFe8iCF+oTvLeBC9Eae3ta4mTwAFZrEkOpoxlrUAPyslOvtK0yi3vOgcMyTMZHPPiWICLw9kcruIH6+G5ArQXpQXihLBR8m0ITM/BMds7+gjWKj2mldrNRmsYuJnt9O0bicY7/M0nLdY+qnBO+9q5tT5LZ94akyKYJPr0b/N+a2ZPgJpRJkhZD9YC4SNTeILNRkhSiygXF66WBDyRLNnoGvdHLu4QO199hx4bh/2Cj5b6tmD+pJvCEtFZJTsel+Hsx1ak1+wY+wByS3DTumipqdx8Hg==",
      "User-Agent": "axios/1.5.1",
      "Content-Length": "288",
      "Accept-Encoding": "gzip, compress, deflate, br",
    },
    method: "post",
    url: "https://api.weixin.qq.com/cgi-bin/express/intracity/queryorder?access_token=73",
    data: "{\"iv\":\"DOIfvxuZJ2TLRjfc\",\"data\":\"2ozy7HDoW63Nd8BQ8L1U6vCZndN1USXANvA+nMNxHBAgjcGjF/pRNoDUist8+21qzuZ5Es88+NSslKEox2y6o/oMTShrH4dGWrpHORHBijhwdN8fwH1eF5GOPOsbqX4SUHlfDk1sPzxfASOy1amsMYzIDsLeN/jQ9309thRH1NAymjF8eK0t5kOX7EauTZUurEmKw5iIT3GK9ALuowYu1g==\",\"authtag\":\"SjxCh/eAA1Rjas5IbAxDog==\"}",
  },
  request: {
    _eventsCount: 7,
    _maxListeners: undefined,
    outputData: [
    ],
    outputSize: 0,
    writable: true,
    destroyed: false,
    _last: true,
    chunkedEncoding: false,
    shouldKeepAlive: false,
    maxRequestsOnConnectionReached: false,
    _defaultKeepAlive: true,
    useChunkedEncodingByDefault: true,
    sendDate: false,
    _removedConnection: false,
    _removedContLen: false,
    _removedTE: false,
    strictContentLength: false,
    _contentLength: "288",
    _hasBody: true,
    _trailer: "",
    finished: true,
    _headerSent: true,
    _closed: false,
    _header: "POST /cgi-bin/express/intracity/queryorder?access_token=73 HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json\r\nWechatmp-Appid: appid\r\nWechatmp-TimeStamp: 1697653176\r\nWechatmp-Signature: 5LK+EUZQPFu4mdxNMigcddkzy4kbBkZauiaHxqLuM58QCmrf3/EciyXteO3OFe8iCF+oTvLeBC9Eae3ta4mTwAFZrEkOpoxlrUAPyslOvtK0yi3vOgcMyTMZHPPiWICLw9kcruIH6+G5ArQXpQXihLBR8m0ITM/BMds7+gjWKj2mldrNRmsYuJnt9O0bicY7/M0nLdY+qnBO+9q5tT5LZ94akyKYJPr0b/N+a2ZPgJpRJkhZD9YC4SNTeILNRkhSiygXF66WBDyRLNnoGvdHLu4QO199hx4bh/2Cj5b6tmD+pJvCEtFZJTsel+Hsx1ak1+wY+wByS3DTumipqdx8Hg==\r\nUser-Agent: axios/1.5.1\r\nContent-Length: 288\r\nAccept-Encoding: gzip, compress, deflate, br\r\nHost: api.weixin.qq.com\r\nConnection: close\r\n\r\n",
    _keepAliveTimeout: 0,
    _onPendingData: () => {},
    socketPath: undefined,
    method: "POST",
    maxHeaderSize: undefined,
    insecureHTTPParser: undefined,
    joinDuplicateHeaders: undefined,
    path: "/cgi-bin/express/intracity/queryorder?access_token=73_",
    _ended: true,
    res: {
      _readableState: {
        objectMode: false,
        highWaterMark: 16384,
        buffer: {
          head: null,
          tail: null,
          length: 0,
        },
        length: 0,
        pipes: [
        ],
        flowing: true,
        ended: true,
        endEmitted: true,
        reading: false,
        constructed: true,
        sync: true,
        needReadable: false,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        errorEmitted: false,
        emitClose: true,
        autoDestroy: true,
        destroyed: true,
        errored: null,
        closed: true,
        closeEmitted: true,
        defaultEncoding: "utf8",
        awaitDrainWriters: null,
        multiAwaitDrain: false,
        readingMore: true,
        dataEmitted: true,
        decoder: null,
        encoding: null,
      },
      _eventsCount: 4,
      _maxListeners: undefined,
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: "1.1",
      complete: true,
      rawHeaders: [
        "Connection",
        "close",
        "Content-Type",
        "text/plain",
        "Date",
        "Wed, 18 Oct 2023 18:27:31 GMT",
        "Wechatmp-Appid",
        "appid",
        "Wechatmp-TimeStamp",
        "1697653651",
        "Wechatmp-Serial",
        "8f60d9c2510d38f3ecaa3b2e8d3b0142",
        "Wechatmp-Signature",
        "foURexH30z6Vq09VmAczYSHYurdmuwDWLMeMgqKm7GlhWkUilS7+35BxIH+RdFHkdqHvmEm7ZPtuyOePyNxyCwnxKAjlNy7+ecKbNlugFEzW4gGjO5f/kL01yqkQeR5Z1UtAot+hADqhaaz+6jtX5CyqUGIGJtS0d+CyD89VnLVk/NjW/DF5J3xIchyHPhytOIiF6gbXCXvaGcu9km8W4fKZOaFfxGAVrHux6PwMVT4Q+j9+HJhunqMG+U2YZLCuLW5oYR7UfHZ9InvNNB3f76nPe64GxPXH81F8zgWqZMJXHBxNZAx2PC99/AEdVMlokoVb6Ij3d2j5cPF3WIYalw==",
        "Content-Length",
        "305",
      ],
      _consuming: false,
      _dumped: false,
      req: [Circular],
      responseUrl: "https://api.weixin.qq.com/cgi-bin/express/intracity/queryorder?access_token=73_",
      redirects: [
      ],
    },
      _ended: true,
      _ending: true,
      _redirectCount: 0,
      _redirects: [
      ],
      _requestBodyLength: 288,
      _requestBodyBuffers: [
      ],
      _onNativeResponse: function (response) {
        self._processResponse(response);
      },
      _currentRequest: [Circular],
      _currentUrl: "https://api.weixin.qq.com/cgi-bin/express/intracity/queryorder?access_token=73_",
    },
  },
  data: {
    iv: "yhi5QzsMLJY6PNll",
    data: "jTGIhh3qrOrEuZaNdnCX0KTWxCDFP/lg6UmO0w/WiEaDH0rQK+7v3aO2AAturcKO5AeFoYmv/muAUeeXQGbgphFysVXRrbh8/ZafuIbMFPzbZ3L2s7dCY70AGF13yk4hyJGMjPlgjZIATN+pD4KZ99PPKmjdqCUU3kWFatxjgbS93Aw3xziFKPKWVlqanF41eGEbNYYtGYBO1/eOR2g2dpKXdh1NTSGzuANO",
    authtag: "9VK7NRTda6zmNwQ9OspeMw==",
  },
}


这个是 ApiMan 生成的代码参数:

返回数据
{
	"errcode": 40234,
	"errmsg": "invalid signature rid: 653023cb-5d07d341-4b375b18"
}




import axios from "axios";


const options = {
  method: 'POST',
  url: 'https://api.weixin.qq.com/cgi-bin/express/intracity/queryorder',
  params: {
    access_token: '73_'
  },
  headers: {
    'Api-Origin': 'PC',
    'App-Origin': 'http://127.0.0.1:2001',
    'Wechatmp-Appid': 'appid',
    'Wechatmp-TimeStamp': '1697653176',
    'Wechatmp-Signature': '5LK+EUZQPFu4mdxNMigcddkzy4kbBkZauiaHxqLuM58QCmrf3/EciyXteO3OFe8iCF+oTvLeBC9Eae3ta4mTwAFZrEkOpoxlrUAPyslOvtK0yi3vOgcMyTMZHPPiWICLw9kcruIH6+G5ArQXpQXihLBR8m0ITM/BMds7+gjWKj2mldrNRmsYuJnt9O0bicY7/M0nLdY+qnBO+9q5tT5LZ94akyKYJPr0b/N+a2ZPgJpRJkhZD9YC4SNTeILNRkhSiygXF66WBDyRLNnoGvdHLu4QO199hx4bh/2Cj5b6tmD+pJvCEtFZJTsel+Hsx1ak1+wY+wByS3DTumipqdx8Hg==',
    'content-type': 'application/json'
  },
  data: {
    iv: 'DOIfvxuZJ2TLRjfc',
    data: '2ozy7HDoW63Nd8BQ8L1U6vCZndN1USXANvA+nMNxHBAgjcGjF/pRNoDUist8+21qzuZ5Es88+NSslKEox2y6o/oMTShrH4dGWrpHORHBijhwdN8fwH1eF5GOPOsbqX4SUHlfDk1sPzxfASOy1amsMYzIDsLeN/jQ9309thRH1NAymjF8eK0t5kOX7EauTZUurEmKw5iIT3GK9ALuowYu1g==',
    authtag: 'SjxCh/eAA1Rjas5IbAxDog=='
  }
};


axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});



看到了嘛?参数一样,返回的结果不一样,我还有一段12分钟长的视频证据,所以,到底是什么问题呢???

希望可以尽快的得到一个满意的答复!

回答关注问题邀请回答
收藏
登录 后发表内容