norzechowicz/promosms-api

PromoSMS.pl API 客户端。

dev-master / 1.0.x-dev 2013-06-16 16:46 UTC

This package is auto-updated.

Last update: 2024-09-06 12:52:01 UTC


README

##PromoSMS.pl 服务的完全面向对象的 API

API 正在开发中,但您可以通过 composer 安装它。

"require": {
    "norzechowicz/promosms-api": "1.0.x-dev"
}

以下代码示例展示了如何发送短信和获取投递报告。

<?php

require __DIR__ . '/vendor/autoload.php';

use PromoSMS\Api\Client;
use PromoSMS\Api\Sms\Sms;

$client = new Client('login@email.com', md5('password'));

$sms = new Sms();
$sms->setReceiver('123123123');
$sms->setMessage('This new message');

$response = $client->send($sms);

if ($response->isValid()) {
    // Get sms delivery report
    $report = $client->report($response->getId());
    echo "SMS id: " . $response->getId() . "\n";

    if ($report->isReceived()) {
        echo "SMS was received at: " . $report->getTime()->format('Y-m-d H:i:s') . "\n";
    } else {
        echo "SMS wasn't received yet. Please check later.\n";
    }
} else {
    // If something went wrong check the status
    // Full status list is available here: http://dev.promosms.pl/sms-api/HTTP_SSL_API#Statusy_zwracane_przez_system
    echo "Error status code: " . $response->getStatus();
}

以下代码示例展示了如何检查账户余额。

<?php

require __DIR__ . '/vendor/autoload.php';

use PromoSMS\Api\Client;
use PromoSMS\Api\Sms\Sms;

$client = new Client('login@email.com', md5('password'));
echo "Current account balance is: " . $client->balance()->getAmount() / 100 . "\n";

###待办事项

  • 添加 MaxSMS 支持
  • 添加 FasterSMS 支持
  • 添加功能以检查文本消息内容将发送多少条短信。