微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Laravel Guzzler API 请求到 SENDGRID

如何解决Laravel Guzzler API 请求到 SENDGRID

我正在尝试使用 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"}]}  

这是我的代码删除了 API TOKEN):

$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 Requirements Image

API 文档链接https://sendgrid.com/docs/api-reference/#message.content

我猜这是我创建数组的方式(或不是...)。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。