sendinblue / sendinblue-api-bundle
v2.0.10
2017-01-04 12:50 UTC
Requires
- php: >=5.3
- symfony/framework-bundle: 2.*|3.*
README
注意:最新的 API V3.0 ( LTS ) 现在由
https://github.com/sendinblue/
维护,文档在此处提供https://developers.sendinblue.com
这是 SendinBlue 提供的 API V2 Symfony Bundle。它实现了各种公开的API,您可以在 https://apidocs.sendinblue.com 上了解更多信息。
先决条件
此版本的bundle需要Symfony 2.x 或 3.x。
安装
使用composer下载SendinBlueApiBundle
在您的 composer.json
中添加 SendinBlueApiBundle
"require": {
"sendinblue/sendinblue-api-bundle": "2.0.*"
}
}```
Now tell composer to download the bundle by running the command:
```bash
$ composer update
或者
运行以下命令进行安装
$ composer require "sendinblue/sendinblue-api-bundle"
Composer会将bundle安装到您的项目的 vendor/sendinblue
目录中。
启用Bundle
在kernel app/AppKernel.php
中
<?php public function registerBundles() { $bundles = array( // ... new SendinBlue\SendinBlueApiBundle\SendinBlueApiBundle(), ); }
添加SendinBlue API密钥
在您的 app/config/config.yml
中
sendin_blue_api: api_key: <Your access key> # Our library supports a timeout value, which is an optional parameter, default is 30,000 MS ( 30 secs ) timeout: 5000
用法
API可通过 sendinblue_api
服务使用。要访问它,请在控制器中添加(或其他地方)
<?php $sendinblue = $this->get('sendinblue_api');
示例
获取您的账户信息
<?php $sendinblue = $this->get('sendinblue_api'); $result = $sendinblue->get_account(); // var_dump($result);
发送邮件
<?php $sendinblue = $this->get('sendinblue_api'); $data = array( "to" => array("to@example.net"=>"to whom!"), "cc" => array("cc@example.net"=>"cc whom!"), "bcc" => array("bcc@example.net"=>"bcc whom!"), "replyto" => array("replyto@email.com","reply to!"), "from" => array("from@email.com","from email!"), "subject" => "My subject", "text" => "This is the text", "html" => "This is the <h1>HTML</h1><br/> This is inline image 1.<br/> <img src=\"{myinlineimage1.png}\" alt=\"image1\" border=\"0\"><br/> Some text<br/> This is inline image 2.<br/> <img src=\"{myinlineimage2.jpg}\" alt=\"image2\" border=\"0\"><br/> Some more text<br/> Re-used inline image 1.<br/> <img src=\"{myinlineimage1.png}\" alt=\"image3\" border=\"0\">", "attachment" => array(), "headers" => array("Content-Type"=> "text/html; charset=iso-8859-1","X-param1"=> "value1", "X-param2"=> "value2","X-Mailin-custom"=>"my custom value", "X-Mailin-IP"=> "102.102.1.2", "X-Mailin-Tag" => "My tag"), "inline_image" => array("myinlineimage1.png" => "your_png_files_base64_encoded_chunk_data","myinlineimage2.jpg" => "your_jpg_files_base64_encoded_chunk_data") ); $result = $sendinblue->send_email($data); // var_dump($result);
支持和反馈
请务必访问SendinBlue官方 文档网站 获取有关我们API的更多信息。
如果您发现错误,请直接在 Github 中提交问题。
如需进一步帮助,请在此处留言 here。