让我的ColdFusion应用程序使用API与Sendgrid的v2 API集成有问题。我的解决方案已经使用用户名/密码多年了,但是切换到API之后,我发现了一些不对劲的地方。我尝试过几种不同的吐露方式,但到目前为止都没有奏效:
<cfhttp method="POST" url="https://sendgrid.com/api/mail.send.json?api_user=apikey&api_key=[my key]" resolveurl="no" timeout="60" result="mailSent">
<cfhttpparam type="formField" name="to" value="to@email.com">
<cfhttpparam type="formField" name="from" value="from@email.com">
<cfhttpparam type="formField" name="fromname" value="Test User">
<cfhttpparam type="formField" name="subject" value="Test Send">
<cfhttpparam type="formField" name="text" value="This is a test">
</cfhttp><cfhttp method="POST" url="https://sendgrid.com/api/mail.send.json" resolveurl="no" timeout="60" result="mailSent">
<cfhttpparam type="formField" name="to" value="to@email.com">
<cfhttpparam type="formField" name="from" value="from@email.com">
<cfhttpparam type="formField" name="fromname" value="Test User">
<cfhttpparam type="formField" name="subject" value="Test Send">
<cfhttpparam type="formField" name="text" value="This is a test">
<cfhttpparam type="formField" name="api_user" value="apikey">
<cfhttpparam type="formField" name="api_key" value="[my key]">
</cfhttp><cfhttp method="POST" url="https://sendgrid.com/api/mail.send.json" resolveurl="no" timeout="60" result="mailSent">
<cfhttpparam type="formField" name="to" value="to@email.com">
<cfhttpparam type="formField" name="from" value="from@email.com">
<cfhttpparam type="formField" name="fromname" value="Test User">
<cfhttpparam type="formField" name="subject" value="Test Send">
<cfhttpparam type="formField" name="text" value="This is a test">
<cfhttpparam type="header" name="api_user" value="apikey">
<cfhttpparam type="header" name="api_key" value="[my key]">
</cfhttp><cfhttp method="POST" url="https://sendgrid.com/api/mail.send.json" resolveurl="no" timeout="60" result="mailSent">
<cfhttpparam type="formField" name="to" value="to@email.com">
<cfhttpparam type="formField" name="from" value="from@email.com">
<cfhttpparam type="formField" name="fromname" value="Test User">
<cfhttpparam type="formField" name="subject" value="Test Send">
<cfhttpparam type="formField" name="text" value="This is a test">
<cfhttpparam type="cgi" name="api_user" value="apikey">
<cfhttpparam type="cgi" name="api_key" value="[my key]">
</cfhttp>帮助?
发布于 2020-11-20 16:17:02
我想我想明白了。在浏览这个代码库之后:
https://github.com/mjclemente/sendgrid.cfc/blob/master/sendgrid.cfc
...it看起来需要的语法如下:
<cfhttp method="POST" url="https://sendgrid.com/api/mail.send.json" resolveurl="no" timeout="60" result="mailSent">
<cfhttpparam type="formField" name="to" value="to@email.com">
<cfhttpparam type="formField" name="from" value="from@email.com">
<cfhttpparam type="formField" name="fromname" value="Test User">
<cfhttpparam type="formField" name="subject" value="Test Send">
<cfhttpparam type="formField" name="text" value="This is a test">
<cfhttpparam type="header" name="Authorization" value="Bearer [my key]">
</cfhttp>https://stackoverflow.com/questions/64932793
复制相似问题