我只需要验证发送域和API密钥。现在我使用curl:
curl
-H "Content-Type: application/json"
-H "Authorization: <REPLACE_WITH_YOUR_API_KEY>"
-X POST -d '{"options":{"open_tracking":true,"click_tracking":true},"metadata":{"some_useful_metadata":"testing_sparkpost"},"substitution_data":{"signature":"<REPLACE_WITH_YOUR_FIRST_AND_LAST_NAME>"},"recipients":[{"address":{"email":"<REPLACE_WITH_YOUR_EMAIL_ADDRESS>"},"tags":["learning"],"substitution_data":{"customer_type":"Platinum","first_name":"<REPLACE_WITH_YOUR_FIRST_NAME>"}}],"content":{"from":{"name":"Awesome Company","email":"testing@<REPLACE_WITH_YOUR_SENDING_DOMAIN>"},"subject":"My first SparkPost Transmission","text":"Hi {{first_name}}rnYou have just sent your first email through SparkPost!rnCongratulations,rn{{signature}}","html":"<strong>Hi {{first_name}},</strong><p>You have just sent your first email through SparkPost!</p><p>Congratulations!</p>{{signature}}"}}'
https://api.sparkpost.com/api/v1/transmissions
这个url给我发了一封电子邮件,所以它是正确的,但我必须使用一个不发送电子邮件,但验证API密钥和发送域的正确性的url。有人能帮我吗?
听起来您想验证两件事:
- 您的API密钥能够发送传输(电子邮件) 您可以使用发送域发送的
要做到这一点,您可以使用与问题中相同的cURL命令,但将.sink.sparkpostmail.com
附加到域的末尾。如果您的API密钥和发送域是正确的,那么将返回200,但不会发送电子邮件(但是发送仍然会对您的使用进行计数)。你可以在这里了解更多关于天坑的信息。
或者,您可以使用发送域页面或发送域API来查看域的状态。您可以使用凭据页面来验证您的API密钥具有"传输:读/写"权限