comsolit/imasys-php

Swissphone的IMASYS移动消息短信服务的PHP包装器

v1.0.3 2015-08-24 16:27 UTC

This package is auto-updated.

Last update: 2024-08-28 13:55:56 UTC


README

IMASYS PHP

IMASYS PHP是Swissphone的IMASYS XML API的PHP包装器。当前功能包括发送短信和检查消息状态。

示例:发送短信并获取消息状态

1. 输入凭据

$credentials = new Credentials('<YOUR_IMASYS_USER_ID>', '<YOUR_IMASYS_PASSWORD>');

2. 获取门户列表

$portalServers = PortalServers::fetchPortalServers($config['host'], $credentials);

3. 初始化连接

$connection = new Connection($credentials, $portalServers);

4. 发送消息

$sendMessageRequest = new SendMessageRequest('<THE MESSAGE>', '<PHONE_NUMBER>', '<ORIGINATOR_NAME>');
$sendMessageResponse = $connection->send($sendMessageRequest);

5. 获取消息状态

sleep(10);
$batchStatusRequest = new BatchStatusRequest($sendMessageResponse->getBatchId());
$batchStatusResponse = $connection->send($batchStatusRequest);

foreach ($batchStatusResponse->getBatch()->getMessages() as $message) {
    print_r($message->getStatus());
}

调用sleep函数的原因是等待消息到达目标。

参考