【发布时间】:2017-04-19 19:05:28
【问题描述】:
按照https://github.com/sendgrid/sendgrid-php/blob/master/examples/contactdb/contactdb.php 的示例,尝试使用 Sendgrid API 创建自定义联系人表单以将收件人添加到联系人列表中,目前我有:
require("sendgrid-php.php");
// Send an Email
$from = new SendGrid\Email(null, "info@test.com");
$subject = "Hello World from the SendGrid PHP Library!";
$to = new SendGrid\Email(null, "my@email.com");
$content = new SendGrid\Content("text/plain", "Hello, Email!");
$mail = new SendGrid\Mail($from, $subject, $to, $content);
$apiKey = 'API_GOES_HERE';
$sg = new \SendGrid($apiKey);
$list_id = "12345";
$recipient_id = base64_encode("test@email.com");
$listResponse = $sg->client->contactdb()->lists()->_($list_id)->recipients()->_($recipient_id)->post();
echo $listResponse->statusCode();
echo $listResponse->body();
echo $listResponse->headers();
但我得到了错误:
**message":"Recipient ID does not exist"**
【问题讨论】: