PHPackages                             hedeqiang/easyjiguang - 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. hedeqiang/easyjiguang

ActiveLibrary

hedeqiang/easyjiguang
=====================

极光 API Server SDK for PHP

v2.0.6(4y ago)127642MITPHPPHP &gt;=7.0

Since Oct 16Pushed 2y ago2 watchersCompare

[ Source](https://github.com/hedeqiang/EasyJiGuang)[ Packagist](https://packagist.org/packages/hedeqiang/easyjiguang)[ RSS](/packages/hedeqiang-easyjiguang/feed)WikiDiscussions v2.1.x Synced today

READMEChangelog (9)Dependencies (4)Versions (11)Used By (0)

 JIGuang
========

[](#-jiguang)

 极光 API Server SDK for PHP.

[![Latest Stable Version](https://camo.githubusercontent.com/857282047254c36ba9f1cd08ad7af73de16ec8084800f0f37db71852332e47ec/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f656173796a696775616e672f76)](//packagist.org/packages/hedeqiang/easyjiguang)[![Total Downloads](https://camo.githubusercontent.com/eb8be9fa1b54ef2a8d9b5f104b5e2252cb04b5a46a48a26921cae19279618695/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f656173796a696775616e672f646f776e6c6f616473)](//packagist.org/packages/hedeqiang/easyjiguang)[![Latest Unstable Version](https://camo.githubusercontent.com/9e2f7102679b628db6d22024121a5fff06746f54be47904048e53614ab8cbbe9/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f656173796a696775616e672f762f756e737461626c65)](//packagist.org/packages/hedeqiang/easyjiguang)[![License](https://camo.githubusercontent.com/e56ad774169fa3696f3be0a95774fd3448300ca27d0a6a8e26924151657f31dd/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f656173796a696775616e672f6c6963656e7365)](//packagist.org/packages/hedeqiang/easyjiguang)

> 如需友盟推送 请前往 [友盟推送](https://github.com/hedeqiang/UMeng-Push)

目前支持以下：

- 推送
- 认证
- 短信
- 魔链

配置
--

[](#配置)

在使用本扩展之前，你需要去 [极光](https://www.jiguang.cn/) 注册账号，进入开发者平台，然后创建应用，获取应用的 appKey 和 masterSecret。

Installing
----------

[](#installing)

```
$ composer require hedeqiang/easyjiguang -vvv
```

Usage
-----

[](#usage)

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

$config = [
    'appKey'       => 'XXX',
    'masterSecret' => 'XXX',

    'groupKey'    => 'XXX',
    'groupSecret' => 'XXX',

    'devKey'        => 'XXX',
    'devSecret'     => 'XXX',

    /*
     * 指定 API 调用返回结果的类型：array(default)/collection/object/raw/自定义类名
     */
    'response_type' => 'array',

    /**
     * 日志配置
     *
     * level: 日志级别, 可选为：
     *         debug/info/notice/warning/error/critical/alert/emergency
     * path：日志文件位置(绝对路径!!!)，要求可写权限
     */
    'log'           => [
        'default'  => env('APP_DEBUG', false) ? 'dev' : 'prod', // 默认使用的 channel，生产环境可以改为下面的 prod
        'channels' => [
            // 测试环境
            'dev'  => [
                'driver' => 'single',
                'path'   => '/tmp/push.log',
                'level'  => 'debug',
            ],
            // 生产环境
            'prod' => [
                'driver' => 'daily',
                'path'   => '/tmp/push.log',
                'level'  => 'info',
            ],
        ],
    ],
];
$app = \EasyJiGuang\Factory::JPush($config);
```

Push API
--------

[](#push-api)

> 请求参数详见：[http://docs.jiguang.cn/jpush/server/push/rest\_api\_v3\_push/](http://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/)

### 推送消息

[](#推送消息)

```
$options = [
    'platform' => 'all',
    'audience' => ['registration_id' => ['1']],
    'notification' => [
        'alert' => 'Hello',
        'android' => [],
        'ios' => [
            'extras' => ['newsid' => '123']
        ]
    ],
    ...
];
return $app->push->message($options);
```

### 推送唯一标识符

[](#推送唯一标识符)

```
$options = [
   'count' => 1,
   'type'  => 'push',
];
return $app->push->getCid($options);
```

### 推送校验

[](#推送校验)

```
$options = [
    ...
    // 该 API 只用于验证推送调用是否能够成功，
    // 与推送 API 的区别在于：不向用户发送任何消息。 其他字段说明：同推送 API
];
return $app->push->validate($options);
```

### 批量单推 针对的是RegID方式批量单推

[](#批量单推-针对的是regid方式批量单推)

```
$options = [
    ...
];
return $app->push->batchRegidSingle($options);
```

### 批量单推 针对的是Alias方式批量单推

[](#批量单推-针对的是alias方式批量单推)

```
$options = [
    ...
];
return $app->push->batchAliasSingle($options);
```

### 推送撤销

[](#推送撤销)

```
return $app->push->revoke($msgid);
```

### 文件推送

[](#文件推送)

```
$options = [
    ...
    'audience' => [
        'file' => ['file_id' => 'xxxx']
    ]
];
return $app->push->file($options);
```

### Group Push API：应用分组推送

[](#group-push-api应用分组推送)

```
$options = [
    ...
];
return $app->push->groupPush($options);
```

### 应用分组文件推送（VIP专属接口）

[](#应用分组文件推送vip专属接口)

```
$options = [
    ...
];
return $app->push->groupPushFile($options);
```

File API
--------

[](#file-api)

> 请求参数详见：[http://docs.jiguang.cn/jpush/server/push/rest\_api\_v3\_file/](http://docs.jiguang.cn/jpush/server/push/rest_api_v3_file/)

### 上传文件

[](#上传文件)

```
$type = 'registration_id'; //type 文件类型，当前可取值为： alias、registration_id，不能为空。
return $app->file->files($type,['filename' => 'xxx.txt']);
```

### 查询文件有效列表

[](#查询文件有效列表)

```
return $app->file->getFiles();
```

### 删除文件

[](#删除文件)

```
return $app->file->deleteFiles($file_id);
```

### 查询指定文件详情

[](#查询指定文件详情)

```
return $app->file->getFilesById($file_id);
```

Report API
----------

[](#report-api)

> 请求参数详见：[http://docs.jiguang.cn/jpush/server/push/rest\_api\_v3\_report/](http://docs.jiguang.cn/jpush/server/push/rest_api_v3_report/)

### 送达统计详情（新）

[](#送达统计详情新)

```
$query = [
    'msg_ids' => '1613113584,1229760629'
];
return $app->report->received($query);
```

### 送达状态查询

[](#送达状态查询)

```
$options = [
    'msg_id' => '',
    'registration_ids' => '',
    'date' => '' //可选
];
return $app->report->status($options);
```

### 消息统计详情（VIP 专属接口，新）

[](#消息统计详情vip-专属接口新)

```
$query = [
    'msg_ids' => '1613113584,1229760629'
];
return $app->report->detail($query);
```

### 用户统计（VIP 专属接口）

[](#用户统计vip-专属接口)

```
$options = [
    'time_unit' => '',
    'start' => '',
    'duration' => ''
];
return $app->report->users($options);
```

### 分组统计-消息统计（VIP 专属接口）

[](#分组统计-消息统计vip-专属接口)

```
$query = [
    'group_msgids' => '1613113584,1229760629'
];
return $app->report->groupUsers($query);
```

### 分组统计-用户统计（VIP 专属接口）

[](#分组统计-用户统计vip-专属接口)

```
$options = [
    'time_unit' => '',
    'start' => '',
    'duration' => ''
];
return $app->report->groupUsers($options);
```

Device API
----------

[](#device-api)

> 请求参数详见：[http://docs.jiguang.cn/jpush/server/push/rest\_api\_v3\_device/](http://docs.jiguang.cn/jpush/server/push/rest_api_v3_device/)

### 查询设备的别名与标签

[](#查询设备的别名与标签)

```
return $app->device->getDevices($registration_id);
```

### 设置设备的别名与标签

[](#设置设备的别名与标签)

```
$options = [
    'tags'   => [
        'add'    => ['tag1', 'tag2'],
        'remove' => ['tag3', 'tag4']
    ],
    'alias'  => 'alias1',
    'mobile' => '13012345678'
];
return $app->device->updateDevices($registration_id,$options);
```

### 查询别名

[](#查询别名)

```
return $app->device->getAliases($alias_value, $platform = ['platform ' => 'all']);
```

### 删除别名

[](#删除别名)

```
return $app->device->deleteAliases($alias_value, $platform = ['platform ' => 'all']);
```

### 解绑设备与别名的绑定关系

[](#解绑设备与别名的绑定关系)

```
$options = [
    'registration_ids' => [
        'remove' => ['registration_id1','registration_id2']
    ]
];
return $app->device->removeAliases($alias_value, $options);
```

### 查询标签列表

[](#查询标签列表)

```
return $app->device->getTags();
```

### 判断设备与标签绑定关系

[](#判断设备与标签绑定关系)

```
return $app->device->isDeviceInTag($tag_value,$registration_id);
```

### 更新标签

[](#更新标签)

```
$options = [
    'registration_ids' => [
        'add' => ['registration_id1','registration_id2'],
        'remove' => ['registration_id1','registration_id2']
    ]
];
return $app->device->updateTag($tag_value,$options);
```

### 删除标签

[](#删除标签)

```
return $app->device->deleteTag($tag_value,$platform = ['platform ' => 'all']);
```

### 获取用户在线状态（VIP 专属接口）

[](#获取用户在线状态vip-专属接口)

```
$options = [
    'registration_ids' => ['010b81b3582','0207870f1b8','0207870f9b8']
];
return $app->device->status($options);
```

极光认证
----

[](#极光认证)

> 请求参数 详见： [https://docs.jiguang.cn/jverification/server/rest\_api/rest\_api\_summary/](https://docs.jiguang.cn/jverification/server/rest_api/rest_api_summary/)

```
$app = \EasyJiGuang\Factory::JVerify($config);

$options = [
    'token' => 'xxx',
    'phone' => 'xxx',
    'exID'  => 'xxx',
];
// 号码认证 提交手机号码和token，验证是否一致
$app->verify->verify($options);
// 一键登录 提交loginToken，验证后返回手机号码
$app->verify->loginTokenVerify('xxx','xxx');
```

More...

在 Laravel 中使用
-------------

[](#在-laravel-中使用)

### 发布配置文件

[](#发布配置文件)

```
php artisan vendor:publish --tag=jiguang
or
php artisan vendor:publish --provider="EasyJiGuang\Providers\JiGuangServiceProvider"
```

### 使用

[](#使用)

#### 服务名访问

[](#服务名访问)

```
public function index()
{
    return app('push')->push->message($options);
}
```

#### Facades 门面使用(可以提示)

[](#facades-门面使用可以提示)

```
use EasyJiGuang\Facades\EasyJiGuang;

public function index()
{
    return EasyJiGuang::JPush()->push->message($options);
}
```

### 其他门面

[](#其他门面)

```
EasyJiGuang::JVerify()->verify->verify();
.
.
.
```

更多用法参考：

- [http://docs.jiguang.cn/jpush/server/push/server\_overview/](http://docs.jiguang.cn/jpush/server/push/server_overview/)
- [https://docs.jiguang.cn/jverification/server/rest\_api/rest\_api\_summary/](https://docs.jiguang.cn/jverification/server/rest_api/rest_api_summary/)

> 能力有限 不可能都能测试到，（权限问题等）。遇到错误麻烦帮忙改进，谢谢。

鸣谢
==

[](#鸣谢)

[EasyWechat](https://github.com/w7corp/easywechat)

> 文中大量代码来自 EasyWechat ，超哥写的代码简直太优雅、太完美。

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

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/hedeqiang/easyjiguang/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/hedeqiang/easyjiguang/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

工具
--

[](#工具)

[![](https://camo.githubusercontent.com/012b96622220782d301096190643c6eb350439b160468aa724f78b5b0251b727/68747470733a2f2f757079756e2e6c61726176656c636f64652e636e2f75706c6f61642f4a6574427261696e732f6a6574627261696e732d747261696e696e672d706172746e65722e706e67)](https://www.jetbrains.com/?from=easyjiguang)

License
-------

[](#license)

MIT

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.9% 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 ~109 days

Recently: every ~181 days

Total

10

Last Release

1050d ago

Major Versions

v1.0.1 → v2.0.02021-05-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ac33cc87fe5ba7f0b8791f5b3453501e83b55ec9a5a209728817ff119635a72?d=identicon)[hedeqiang](/maintainers/hedeqiang)

---

Top Contributors

[![hedeqiang](https://avatars.githubusercontent.com/u/31909061?v=4)](https://github.com/hedeqiang "hedeqiang (85 commits)")[![housemea](https://avatars.githubusercontent.com/u/55009957?v=4)](https://github.com/housemea "housemea (6 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (5 commits)")[![houseme](https://avatars.githubusercontent.com/u/4829346?v=4)](https://github.com/houseme "houseme (2 commits)")[![rainphp1](https://avatars.githubusercontent.com/u/25108855?v=4)](https://github.com/rainphp1 "rainphp1 (1 commits)")

---

Tags

jlinkjpushjsmsjverifylinkpushverifysmsjiguang

### Embed Badge

![Health badge](/badges/hedeqiang-easyjiguang/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k4](/packages/elgg-elgg)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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