从API发送模板属性

时间:2019-01-31 12:52:45

标签: php sendinblue

我无法从我的网站(API v3)发送其他属性。在模板#1中,我创建文本框架 ID:{{params.postid}} 姓名:{{params.postname}} 并从我的网站运行我的PHP代码。

require_once($_SERVER['DOCUMENT_ROOT'] . '/sendinblue/vendor/autoload.php');
$config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'key');
$apiInstance = new SendinBlue\Client\Api\SMTPApi( new GuzzleHttp\Client(), $config );
$templateId = 1; // int | Id of the template
$sendEmail = new \SendinBlue\Client\Model\SendEmail(); // \SendinBlue\Client\Model\SendEmail | 
$sendEmail ['emailTo'] = ['to-mail@mail.ru'];
$sendEmail ['attributes'] = ['postid'=>'12345', 'postname'=>'Post Title',];
try {
$result = $apiInstance->sendTemplate($templateId, $sendEmail);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SMTPApi->sendTemplate: ', $e->getMessage(), PHP_EOL;
}

成功后,我会收到模板#1的邮件,但postid和postname为空。请帮帮我!

0 个答案:

没有答案