定制 tenko/link-sms 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tenko/link-sms

最新稳定版本:v0.1.5

Composer 安装命令:

composer require tenko/link-sms

包简介

Link Group Third-part Sms SDK

README 文档

README

LinkSMS is a third-part SDK for Link Group SMS Service.

中文文档

Quick Start

  • First: Create a config object
class Config implements \LinkSms\Library\ConfigInterface {
    public function getBaseUrl(): string
    {
        return 'https://sdk3.028lk.com:9988';
    }

    public function getCorpId(): string
    {
        return '[CORP_ID]';
    }

    public function getPassword(): string
    {
        return '[PASSWORD]';
    }

    public function getHeaders(): array
    {
        return [];
    }

    public function getGuzzleConfig(): array
    {
        return [];
    }
}

$config = new Config();

Or you can use an anonymous class like this:

$config = new class implements \LinkSms\Library\ConfigInterface {
    public function getBaseUrl(): string
    {
        return 'https://sdk3.028lk.com:9988';
    }

    public function getCorpId(): string
    {
        return '[CORP_ID]';
    }

    public function getPassword(): string
    {
        return '[PASSWORD]';
    }

    public function getHeaders(): array
    {
        return [];
    }

    public function getGuzzleConfig(): array
    {
        return [];
    }
};
  • If you need to log events, there are also provided interfaces for logging. Here is the usage example:
$log = new class implements \LinkSms\Library\LogInterface {
    public function info(string $message, array $data = [])
    {
        // TODO write info
    }

    public function warning(string $message, array $data = [])
    {
        // TODO write warning
    }

    public function error(string $message, array $data = [])
    {
        // TODO write error
    }
};
  • And then you can start using it.
$sms = new \LinkSms\SmsService($config[, $log]); // It is not necessary to pass a LogInterface

Usage

  • Send message
$sms->sendMessage(
    ['13800008888'],
    'content 【Sign】',
    '', // Cell, must be a numeric string,
    new DateTimeImmutable('2024-01-01 08:00') // It is not necessary unless you need to schedule the sending of text messages.
)
  • Get remain
$remain = $sms->getRemain();
  • Fetch message
/** @var array<\LinkSms\Library\Message> $messages */
$messages = $sms->fetchMessage();

foreach ($messages as $message) {
    $mobile = $message->getMobile();
    
    $content = $message->getContent();
    
    /** @var DateTimeImmutable $sendTime */
    $sendTime = $message->getSendTime();
    $sendTimestamp = $sendTime->getTimestamp();
    
    $cell = $message->getCell();
}

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-08