【问题标题】:Sending Image through GupShup通过 GupShup 发送图像
【发布时间】:2020-11-21 07:43:58
【问题描述】:

尝试通过 GupShup 发送图像。我正在使用他们的沙箱。我的后端是带有feathersjs 的node.js。 但它返回给我这个错误:

Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      readable: true,
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: true,
      _transformState: [Object],
      [Symbol(kCapture)]: false
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://api.gupshup.io/sm/api/v1/msg',
    status: 400,
    statusText: 'Bad Request',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}

这是发送图片的代码

const form = new URLSearchParams();
  form.append('channel', 'whatsapp');
  form.append('destination', destination);
  form.append('source', app.get('GUPSHUP_NUMBER'));
  form.append('message.payload', JSON.stringify(message));
  form.append('src.name', 'OneAccess');
  console.log(form);
  try {
    const res = await fetch('https://api.gupshup.io/sm/api/v1/msg', {
      method: 'POST',
      body: form,
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        apikey: app.get('GUPSHUP_API'),
      },
    });

    console.log('result message', res);
  } catch (err) {
    console.log('errro sending msg', err);
  }

这是我要发送的消息

message: {
        type: 'image',
        originalUrl:
          'https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg',
        previewUrl:
          'https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg',
        caption: 'Sample image',
      },

谁能帮帮我?

【问题讨论】:

    标签: javascript node.js image whatsapp gupshup


    【解决方案1】:

    message.payload 更改为 message。您可以在https://www.gupshup.io/developer/docs/bot-platform/guide/whatsapp-api-documentation#SendImage查看正确的签名

    【讨论】:

      猜你喜欢
      • 2012-08-27
      • 2014-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 2017-01-25
      • 1970-01-01
      相关资源
      最近更新 更多