morannon/morannon-bundle

该软件包已被废弃,不再维护。未建议替代软件包。

Morannon SMS网关的Symfony2扩展包。

0.1.3 2015-01-09 16:30 UTC

This package is not auto-updated.

Last update: 2020-01-24 16:43:17 UTC


README

Build Status Latest Stable Version Total Downloads

支持的服务

包含的服务实现

  • Nexmo
  • WhateverMobile
  • 更多即将到来!

安装

将 morannon-bundle 添加到您的 composer.json 文件中

"require": {
  "morannon/morannon-bundle": "~0.1"
}

使用 composer 安装此软件包。

$ composer update morannon/morannon-bundle

注册扩展包

在您的 app/AppKernel.php 中注册扩展包

    new \Morannon\Bundle\MorannonBundle\MorannonBundle(),

配置

现在将所需的配置添加到 app/config/config.yml

morannon:
    gateways:
        nexmo:
            api_base_url: https://rest.nexmo.com
            api_user: thisismyapiuser
            api_token: thisismyapitoken

这里以 Nexmo 为例。将其替换为您想要的任何服务。现在添加您需要的所有资源所有者,服务将自动创建。

服务

此扩展包将自动创建服务。在我的情况下,我想要 xing 服务

    $service = $this->container->get('morannon.gateways.nexmo');

或者将其注入到另一个服务中

    fancy_company.random_namespace.wayne_bundle:
        class: FancyCompany\Bundle\WayneBundle\MyCool\ClassFor\WorldDominance
        arguments:
            - @morannon.gateways.nexmo

使用方法

对于服务类型提示,请使用 \Morannon\Base\Gateway\GatewayInterface 接口,它提供了 sendSMS 方法。此接口也可以用于方法和构造函数签名的类型提示。

发送短信

sendSMS 方法期望一个 Morannon\Base\SMS\SMSInterface 接口实例。如果您不需要任何特殊功能,可以轻松使用 Morannon\Base\SMS\BaseSMS 实现。

它返回一个 Morannon\Base\Response\SentResponseInterface 接口实例,该实例提供有关已发送短信的信息(例如,getSentMessagesCount(),getMessageId())。