netlabs / sms-gateway-bundle
serwersms.pl API的SMS网关
1.0.0
2014-04-02 14:52 UTC
Requires
- php: >=5.3.3
- symfony/symfony: >=2.1
This package is not auto-updated.
Last update: 2024-09-28 15:29:49 UTC
README
serwersms.pl API的SMS网关
安装
- composer.json
"require": { "netlabs/sms-gateway-bundle": "1.0.*" }
- app/AppKernel.php
new NetLabs\SMSGatewayBundle\NetLabsSMSGatewayBundle()
配置
- app/config/config.yml
net_labs_sms_gateway: # serwersms.pl api: username: testuser password: testpassword
基本用法
发送短信消息
$smsService = $this->get('net_labs_sms'); $message = $smsService->compose() ->setReceiver('123123123') ->setContent('This is a test message.'); $result = $smsService->send($message);
接收 incoming SMS 消息
$smsService = $this->get('net_labs_sms');
$messages = $smsService->receive();
接收消息投递报告
$smsService = $this->get('net_labs_sms');
$reports = $smsService->getReports();
检查消息限制计数器
$smsService = $this->get('net_labs_sms');
$counters = $smsService->getCounters();
HLR - 检查电话号码的主要和当前网络
$smsService = $this->get('net_labs_sms');
$result = $smsService->hlr('123123123');
高级用法
发送短信消息
$smsService = $this->get('net_labs_sms'); $message = $smsService->compose() ->setReceiver('123123123') // receiver's phone number ->setContent('This is a test message.') // message content ->setSenderName('Test Name'); // max 11 chars ->setIsFlash(false) // send as flash message - directly to the screen ->setIsWapPush(false) // send as WapPush message ->setIsUTF8(false) // set encoding to utf8, so you can use for example polish characters (ąśćźńęółż) ->setIsVCard(false) // send as VCard message ->setSentAt(new \DateTime('+1 hour')) // set date for delayed delivery ->setUsmsid(uniqid()); // custom unique message ID $result = $smsService->send($message);
接收 incoming SMS 消息
$smsService = $this->get('net_labs_sms');
$messages = $smsService->receive(
$setAsRead, // sets message as read after receiving, so it won't be received next time
$number, // phone number
$startDate, // date range
$endDate, // date range
$type, // message type
$ndi, // NDI
$getSmsId // gets messages with custom message ID
);
接收消息投递报告
$smsService = $this->get('net_labs_sms');
$reports = $smsService->getReports(
$number, // phone number
$startDate, // date range
$endDate, // date range
$smsId, // smsId from serwersms.pl
$usmsid // custom message ID
);