承接 mrbase/smesg 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mrbase/smesg

最新稳定版本:v1.0

Composer 安装命令:

composer require mrbase/smesg

包简介

Providing wrappers for danish sms gateways

README 文档

README

Smesg is a library to help you send sms messages via different providers.

Currently supported providers:

So far the library only supports sending sms messages, querying for status, canceling and other services will be added.

Installation

Install via composer:

{
    "require": {
        "mrbase/smesg": "*"
    }
}

or clone this repository:

git clone https://github.com/mrbase/Smesg.git Smesg

Usage

First off, you need a contract with one of the provides for you to be able to send anything.

You really sould use a psr-0 compliant autoloader, it will make your day.

A simple one can be found in tests/autoloader.php.

Then you need to set the configure variables for the provider (explained in details below) and provide the transport adapter.

Currently only one transport adapter exists, but you can add your own by implementing the Smesg\Adapter\AdapterInterface.

Unwire example:

<?php

require __DIR__ . '/tests/autoloader.php';

$config = array(
    'user' => 'test',
    'password' => 'test....',
    'appnr' => '1212',
    'mediacode' => 'test',
    'price' => '0.00DK',
);

$transport = new Smesg\Adapter\PhpStreamAdapter();
$provider = new Smesg\Provider\UnwireProvider($transport, $config);

$provider->addMessage('mobile_number', 'message');
$response = $provider->send();

Note, the mobile_number must be a valid MSISDN compliant number or the service will fail!

In-depth docs for the providers

inmobile:

The provider for inmobile implements the following services:

  • smspush
  • smspushxml
  • smsclookup (you need a seperate agreement to have access to this service)

smspush: is used to send single messages.

smspushxml: is used when sending batch messages, note that you can only send 1024 messages in one batch, the provider does not handle the split into seperate batches.

smsclookup: is used to loockup serviceproviders for mobile numbers. implementing a cache for this is on the todo list.

Default configuration values:

<?php

$config = array(
    'user' => '',
    'password' => '',
    'appnr' => '',
    'mediacode' => '',
    'price' => '',
    'get_smsc' => false,
);

Please note that the price format uses period (.) as decimal devider.

Example: 0.00DKK is the correct value if you do not tax the messages in Denmark.

Possible default values when sending batch messages:

$defaults = array(
    'operator' => null,
    'shortcode' => null,
    'mediacode' => null,
    'price' => array(
        'amount' => null,
        'currency' => null,
        'vat' => null,
    ),
    'content' => null,
);

If left alone the price array will be calculated from the value set in the configuration.

If you want to send the same message to a group of people you have the posibility to setup defaults for the messages.

Here is a simple example extending the demo above.

<?php
// ....
$provider = new Smesg\Provider\UnwireProvider($transport, $config);

$provider->setDefaults(array(
    'shortcode' => '1212',
    'mediacode' => 'test',
    'content' => 'this is the message send',
));

$provider->addMessage('mobile_number_1', null);
$provider->addMessage('mobile_number_2', null);
$provider->addMessage('mobile_number_3', null);
$response = $provider->send();

Build Status

统计信息

  • 总下载量: 3.25k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2012-03-12