jihel/mail-xpertise-bundle

处理mailxpertise api的symfony扩展包

安装: 44

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

dev-master 2017-03-20 15:37 UTC

This package is not auto-updated.

Last update: 2024-09-18 20:17:50 UTC


README

一个用于处理mail expertise api的Symfony扩展包。此包仅提供使用Guzzle的php对象方式使用api。

1- 安装

将插件添加到composer.json的require中

{
    "require": {
        "jihel/mail-xpertise-bundle": "dev-master",
    }
}

php composer.phar require jihel/mail-xpertise-bundle:dev-master

将包添加到AppKernel.php中

public function registerBundles()
{
    $bundles = array(
        ...
        new Jihel\Plugin\MailXpertiseBundle\JihelPluginMailXpertise(),
    );
}

2- 配置您的config.yml

默认配置文件和说明可以在这里找到:此处

jihel_plugin_mail_xpertise:
    apiKey: your_api_key
    token: your_api_token
    timeout: 3

3- 使用方法

获取代理服务 jihel.plugin.mail_xpertise.proxy.api

  • 从控制器中

    /** @var \Jihel\Plugin\MailXpertiseBundle\Proxy\ApiProxy $MailXpertiseProxy */ $MailXpertiseProxy = $this->get('jihel.plugin.mail_xpertise.proxy.api');

  • 从服务中

    service: my.super.service: class: %my.super.service.class% arguments: { '@jihel.plugin.mail_xpertise.proxy.api' }

该类提供了一个方法,该方法将返回一个Guzzle客户端对象

/**
 * Get the Guzzle client object.
 * Aditionnal options can be provide, it won't override the one defined by config 
 *
 * @param array $option
 * @return \SplFileObject
 */
public function getClient(array $option = array())

示例

/** @var \Jihel\Plugin\MailXpertiseBundle\Proxy\ApiProxy $MailXpertiseProxy */
$MailXpertiseProxy = $this->get('jihel.plugin.mail_xpertise.proxy.api');
$client = $MailXpertiseProxy->getClient();
$response = $client->get('/api/lists/info');

4- 感谢

感谢我抽出时间编写这个类,方便懒惰的开发者。您可以在这里访问我的简历:此处