tschiemer/aspsms

通过aspsms.com发送短信的服务客户端

1.1.1 2014-05-13 10:40 UTC

This package is auto-updated.

Last update: 2024-09-18 19:56:43 UTC


README

通过aspsms.com发送短信的服务客户端。包含CodeIgniter适配器/演示。

特性

  • SOAP、HTTP和XML aspsms.com服务的接口抽象
  • 简单的接口,适合懒惰的开发者(万岁!),可以是单一服务或组合服务。
  • CodeIgniter库适配器(附带详细演示)
  • 简单的接口清晰的文档

aspsms.com功能

  • 发送文本短信
  • 获取投递状态
  • 发送者(发送者)测试和解锁
  • 令牌发送和验证(也参见http://www.asptoken.com
  • 二进制短信:VCard

需求

  • PHP 5.3
  • CURL扩展(如果使用HTTP或XML驱动程序)
  • SOAP扩展(如果使用SOAP驱动程序)

待办事项

  • XML驱动程序:失败时交替服务器
  • XML服务:sendPicture、sendLogo、sendGroupLogo、sendRingtone、sendBinaryData
  • 错误/异常处理,特别是:区分服务失败和负面回复
  • 了解:短信服务中心4.0 EMI - UCP接口规范短信服务中心(SMSC)外部机器接口(EMI)描述,EmiSpec_44a.pdf

文档

PHP Apigen文档

示例使用

请参考CodeIgniter适配器以获取更详细的演示。

use \tschiemer\Aspsms as Aspsms;

require_once 'lib/tschiemer/autoload.php';

$config = array(
    'userkey'       => 'my-key',
    'password'      => 'my-password',
    'originator'    => 'my-originator'
);

$aspsms = new Aspsms\SimpleClient($config);

// Send trackable SMS
try {
    $success = $aspsms->sendText(array(
        '100' => '0041xxxxxxxx',
        '101' => '0031xxxxxxxx'
        ), 'Hello pretty!');
}
catch (Aspsms\ServiceException $e){
    die('ASPSMS service error: '.$e->getMessage());
}

if ( ! $success )
{
    $statusCode = $aspsms->getLastStatusCode();

    $statusDescription = $aspsms->getStatusDescription($statusCode);
    // or alternatively
    $statusDescription = statusDescriptionString($statusCode);

    die('Unexpected server response status '.$statusCode. ': '.$statusDescription);
}


// Get delivery information
try {
    $status = $aspsms->getDeliveryStatus(array('100','101'));
}
catch (Aspsms\ServiceException $e){
    die('ASPSMS service error: '.$e->getMessage());
}

print_r($status);

echo Aspsms\Strings::deliveryStatus($status['100']['status']);

echo Aspsms\Strings::reasonCode($status['100']['reason']);

输出

array(2) {
  [100]=>
  array(6) {
    [nr]=>"100",
    [status]=>"0",
    [submissionDate]=>"12022014123834",
    [deliveryDate]=>"12022014123840",
    [reason]=>"000",
    [other]=>""
  },
  [101]=>
  array(6) {
    [nr]=>"101",
    [status]=>"0",
    [submissionDate]=>"12022014123833",
    [deliveryDate]=>"12022014123838",
    [reason]=>"000",
    [other]=>""
  }
}
Delivered
Unknown subscriber

修订历史

1.1.0

  • PSR-0命名空间兼容性和composer/packagist注册
  • 较小的文件名/类名重命名

官方文档

https://webservice.aspsms.com/aspsmsx2.asmx http://www.aspsms.com/xml/doc/xmlsvr191.pdf http://www.aspsms.de/vbscript_class/doc.htm http://www.aspsms.de/newsletter/html/en/200905/

许可:LGPL v3