n1creator/smsru

PHP 类用于操作 sms.ru 服务的 API

dev-master 2024-06-17 10:50 UTC

This package is auto-updated.

Last update: 2024-09-17 11:22:50 UTC


README

https://github.com/zelenin/sms_ru 分支出来

sms_ru

PHP 类用于操作 sms.ru 服务的 API

安装

警告

版本 4 的 API 与之前版本有所不同。

通过 Composer 安装

运行

php composer.phar require n1creator/smsru "dev-master"

或添加以下内容到您的 composer.json 文件中的 require 部分

"n1creator/smsru": "dev-master"

使用方法

简单授权(使用 api_id)

$client = new \N1Creator\SmsRu\Api(new \N1Creator\SmsRu\Auth\ApiIdAuth($apiId), new \N1Creator\SmsRu\Client\Client());

强化授权(使用 api_id、用户名和密码)

$client = new \N1Creator\SmsRu\Api(new \N1Creator\SmsRu\Auth\LoginPasswordSecureAuth($login, $password, $apiId), new \N1Creator\SmsRu\Client\Client());

强化授权(使用用户名和密码)

$client = new \N1Creator\SmsRu\Api(new \N1Creator\SmsRu\Auth\LoginPasswordAuth($login, $password), new \N1Creator\SmsRu\Client\Client());

发送 SMS

$sms1 = new \N1Creator\SmsRu\Entity\Sms($phone1, $text1);
$sms1->translit = 1;
$sms2 = new \N1Creator\SmsRu\Entity\Sms($phone2, $text2);

$client->smsSend($sms1);
$client->smsSend($sms2);

$client->smsSend(new \N1Creator\SmsRu\Entity\SmsPool([$sms1, $sms2]));

SMS 状态

$send = $client->smsSend($sms);
$smsId = $send->ids[0];
$client->smsStatus($smsId);

SMS 成本

$client->smsCost(new \N1Creator\SmsRu\Entity\Sms($phone, $text));

余额

$client->myBalance();

每日限额

$client->myLimit();

发送者

$client->mySenders();

验证用户名和密码的有效性

$client->authCheck();

将号码添加到黑名单

$client->stoplistAdd($phone, $text);

从黑名单中删除号码

$client->stoplistDel($phone);

获取黑名单号码

$client->stoplistGet();