PHPackages                             jiguang/jsms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. jiguang/jsms

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

jiguang/jsms
============

v1.0.9(7y ago)823.5k↑300%4MITPHPPHP &gt;=5.3.3

Since Sep 5Pushed 7y ago15 watchersCompare

[ Source](https://github.com/jpush/jsms-api-php-client)[ Packagist](https://packagist.org/packages/jiguang/jsms)[ RSS](/packages/jiguang-jsms/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)DependenciesVersions (12)Used By (0)

JSMS API PHP CLIENT
===================

[](#jsms-api-php-client)

这是短信 API 的 PHP 版本封装开发包，是由极光官方提供的，一般支持最新的 API 功能。

对应的 API 文档：[https://docs.jiguang.cn/jsms/server/rest\_api\_summary/](https://docs.jiguang.cn/jsms/server/rest_api_summary/)

> 支持的 PHP 版本: 5.3.3 ～ 5.6.x, 7.0.x 须启用 cURL 扩展

Installation
------------

[](#installation)

- 在项目中的 `composer.json` 文件中添加 JSMS 依赖：

```
"require": {
    "jiguang/jsms": "~1.0"
}
```

- 执行 `$ php composer.phar install` 或 `$ composer install` 进行安装。

Usage
-----

[](#usage)

#### 初始化

[](#初始化)

```
use JiGuang\JSMS as JSMS;
...
...

    $client = new JSMS($app_key, $master_secret);

...
```

OR

```
$client = new \JiGuang\JSMS($app_key, $master_secret);
```

#### 证书问题

[](#证书问题)

```
// 禁用 SSL 证书的验证，
$client = new JSMS($app_key, $master_secret, [ 'disable_ssl' => true ]);
```

**希望开发者在了解相关风险的前提下如此处理 SSL 证书问题。**

#### 发送验证码

[](#发送验证码)

```
$client->sendCode($phone, $temp_id, $sign = null);
```

**参数说明:**

> $phone: 接收验证码的手机号码

> $temp\_id: 模板ID

> $sign\_id: 签名ID，null 表示使用应用默认签名

#### 发送语音短信验证码

[](#发送语音短信验证码)

```
$client->sendVoiceCode($phone, $options = []);
```

**参数说明:**

> $phone: 接收验证码的手机号码

> $options: 可选选项数组，接受 3 个键 `ttl`，`code`，`voice_lang` 中的一个或多个。

- ttl: 超时时间，默认为 60 秒
- code: 语音验证码的值，验证码仅支持 4-8 个数字
- voice\_lang: 播报语言选择，0：中文播报，1：英文播报，2：中英混合播报

#### 验证

[](#验证)

```
$client->checkCode($msg_id, $code);
```

**参数说明:**

> $msg\_id: 发送验证码 sendCode 函数返回的数组中的 msg\_id 键对应的值

> $code: 手机接收到的验证码

#### 发送模板短信

[](#发送模板短信)

```
$client->sendMessage($mobile, $temp_id, array $temp_para = [], $time = null, $sign_id = null);
```

**参数说明:**

> $phone: 接收验证码的手机号码

> $temp\_id: 模板 ID

> $temp\_para: 模板参数,需要替换的参数名和 value 的键值对,仅接受数组类型的值

> $time: 定时短信发送时间，格式为 yyyy-MM-dd HH:mm:ss，默认为 `null` 表示立即发送

> $sign\_id: 签名ID，null 表示使用应用默认签名

#### 发送批量模板短信

[](#发送批量模板短信)

```
$client->sendBatchMessage($temp_id, array $recipients，$time = null, sign_id = null, $tag = null);
```

**参数说明:**

> $temp\_id: 模板 ID

> $recipients: 接收者列表，接受一个以 mobile 为键，对应其 temp\_para 为值的关联数组

> $time: 定时短信发送时间，格式为 yyyy-MM-dd HH:mm:ss，默认为 `null` 表示立即发送

> $sign\_id: 签名ID，null 表示使用应用默认签名

> $tag: 标签，仅用作标示该短信的别名，不在短信中展示，最多不超过 10 个字

#### 查询定时模板短信

[](#查询定时模板短信)

```
$client->showSchedule($scheduleId);
```

#### 删除定时模板短信

[](#删除定时模板短信)

```
$client->deleteSchedule($scheduleId);
```

#### 应用余量查询

[](#应用余量查询)

```
$client->getAppBalance();
```

#### 调用返回码说明

[](#调用返回码说明)

[http://docs.jiguang.cn/server/rest\_api\_jsms/#\_12](http://docs.jiguang.cn/server/rest_api_jsms/#_12)

Examples
--------

[](#examples)

在下载的中的 [examples](https://github.com/jpush/jsms-api-php-client/tree/master/examples) 文件夹有简单示例代码, 开发者可以参考其中的样例快速了解该库的使用方法。

> **注：所下载的样例代码不可马上使用，需要在相应文件中填入相关的必要参数，不然示例运行会失败**

#### 简单使用方法

[](#简单使用方法)

> 假定当前目录为 JSMS 源码所在的根目录

- 编辑 `examples/config.php` 文件，填写信息

```
$appKey = 'xxxx';
$masterSecret = 'xxxx';
$phone = 'xxxxxxxxxxx';
```

- 运行示例 `$ php examples/send_example.php`
- 获取 `msg_id` 和 `code`
- 编辑 `examples/check_example.php` 文件，填写信息

```
$msg_id = 'xxxx';
$code = 'xxxxxx';
```

- 运行示例 `$ php examples/check_example.php`

Contributing
------------

[](#contributing)

Bug reports and pull requests are welcome on GitHub at .

License
-------

[](#license)

The library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~106 days

Recently: every ~118 days

Total

10

Last Release

2581d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/574708945000adcca89172b4822f4fb529ab974f84db0bd14dd3dada3a097139?d=identicon)[jpush](/maintainers/jpush)

---

Top Contributors

[![supgeek-rod](https://avatars.githubusercontent.com/u/5748006?v=4)](https://github.com/supgeek-rod "supgeek-rod (1 commits)")

### Embed Badge

![Health badge](/badges/jiguang-jsms/health.svg)

```
[![Health](https://phpackages.com/badges/jiguang-jsms/health.svg)](https://phpackages.com/packages/jiguang-jsms)
```

###  Alternatives

[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[eduardokum/laravel-mail-auto-embed

Library for embed images in emails automatically

1702.0M5](/packages/eduardokum-laravel-mail-auto-embed)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
