我可以通过Meta Cloud API发送whatsapp媒体消息而不上传它们吗?

问题描述 投票:0回答:1

我正在尝试使用 Meta Cloud API 将图像作为 Whatsapp 消息发送,但我不想将其上传到任何地方,我不能只发送二进制缓冲区吗?

类似这样的:

const formData = new FormData();
formData.append('messaging_product', 'whatsapp');
formData.append('recipient_type', 'individual');
formData.append('to', content.to);
formData.append('type', 'image');
formData.append(
    'file',
    content.image_buffer,
    {
        filename: 'image.png',
        contentType: 'image/png',
    }
);

我使用的服务(业务解决方案提供商)允许我直接将图像作为二进制缓冲区发送。现在我将使用 Meta Cloud API,但在文档中没有找到类似的内容

whatsapp whatsapp-cloud-api
1个回答
0
投票

Meta Cloud API 不允许您直接将图像作为二进制缓冲区发送,而不将它们上传到某个地方。为了解决这个问题,您可以将图像上传到临时存储服务,例如 Amazon S3 或 Imgur。然后,您获取上传图像的 URL,并使用它通过 Meta Cloud API 发送图像。这样,您就可以避免永久存储图像,并且仍然可以通过 API 发送图像。

© www.soinside.com 2019 - 2024. All rights reserved.