tilleuls / ymlp-bundle
集成 YMLP API 于 Symfony
v1.1.1
2017-03-13 11:04 UTC
Requires
- php: >=5.4
- guzzlehttp/guzzle: ^4.0
- symfony/config: ^2.3 || ^3.0
- symfony/dependency-injection: ^2.3 || ^3.0
- symfony/http-kernel: ^2.3 || ^3.0
Requires (Dev)
- phpspec/phpspec: ^2.0
This package is auto-updated.
Last update: 2024-08-27 02:34:46 UTC
README
此扩展包将 Your Mailing List Provider (YMLP) API 集成到 Symfony 项目中。
安装
使用 Composer 安装此扩展包
composer require tilleuls/ymlp-bundle
在您的应用程序内核中添加扩展包
// app/AppKernel.php public function registerBundles() { return [ // ... new CoopTilleuls\Bundle\YmlpBundle\CoopTilleulsYmlpBundle(), // ... ]; }
配置
# app/config/config.yml coop_tilleuls_ymlp: # YMLP URL for API calls (default to https://www.ymlp.com/api/) api_url: https://www.ymlp.com/api/ # Your YMLP API key (no default) api_key: YOURSECRETAPIKEY1234 # Your YMLP username (no default) api_username: tilleuls
使用方法
use CoopTilleuls\Bundle\YmlpBundle\Ymlp\Exception\YmlpException; // Get an instance of the YMLP API client as a service $ymlpClient = $this->get('coop_tilleuls_ymlp.client'); // Call the simple Ping() command of the YMLP API $pingResponse = $ymlpClient->call('Ping'); // Add a new contact to one or more groups with exception handling try { $contactsAddResponse = $ymlpClient->call('Contacts.Add', ['Email' => 'baptiste@les-tilleuls.coop', 'GroupID' => 1]); } catch (YmlpException $e) { //... }
call()
方法返回一个包含响应的数组或抛出类型为 \CoopTilleuls\Bundle\YmlpBundle\Ymlp\Exception\YmlpException
的异常。
您可以在 YMLP API 页面 上获得所有 API 命令及其参数和响应的列表(需要 YMLP 凭证)。
致谢
此扩展包由 Baptiste Meyer 为 Les-Tilleuls.coop 编写。