问题描述
我正在尝试使用 SENDGRIDS API 发送电子邮件,但出现以下错误:
[2021-03-12 18:24:46] local.INFO: {"errors":[{"message":"Invalid type. Expected: array,given: object.","field":"personalizations","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#-Personalizations-Errors"}]}
$response = Http::withToken('INSERT TOKEN HERE')
->post('https://api.sendgrid.com/v3/mail/send',[
'template_id' => 'd-189dug8yrfjsbgduufedsufio','subject' => 'Test from Me','from' =>
[
'email' => 'noreply@emailtest.com',],'personalizations' =>
[
'to' =>'testemail@email.com','name' => 'Joe Bloggs','content' => 'Message here'
],]);
API 要求个性化设置为数组(对象),但我终生无法弄清楚!
API 文档链接: https://sendgrid.com/docs/api-reference/#message.content
我猜这是我创建数组的方式(或不是...)。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)