使用WhatsApp API发送文档时,我如何提供名称文件



我试图通过WhatsApp API发送一个文档文件(pdf/docx/ppt等(。根据文档,这是我的代码:

$client = new Client();
$headers = [
'Authorization' => 'Bearer '.config('app.wa_token'),
'Content-Type' => 'application/json'
];
$body = '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "'.$receiver.'",
"type": "document",
"document": {
"link": "'.$link_docx.'",
"caption": "'.$filename.'"
}
}';
$request = new Request('POST', 'https://graph.facebook.com/v13.0/'.$kod.'/messages', $headers, $body);
$res = $client->sendAsync($request)->wait();
return $res->getBody();

但在接收器中,我收到的文件显示为这样的

收到的文件

当我在手机中收到它时,名称为null.pdf

如何使用原始名称发送文档?

document对象可以有一个可选的filename,稍后将显示给收件人。请确保提供一个带有文件扩展名的名称,以便向收件人正确显示该文件。

查看此处了解详细信息。

最新更新