PHPackages                             lokielse/aliyun-open-api-push - 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. [API Development](/categories/api)
4. /
5. lokielse/aliyun-open-api-push

ActiveLibrary[API Development](/categories/api)

lokielse/aliyun-open-api-push
=============================

The Push SDK for Aliyun OpenAPI

v1.0.1(9y ago)4279MITPHPPHP &gt;=5.3.0

Since Jul 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/lokielse/php-aliyun-open-api-push)[ Packagist](https://packagist.org/packages/lokielse/aliyun-open-api-push)[ Docs](https://github.com/lokielse/aliyun-open-api-push)[ RSS](/packages/lokielse-aliyun-open-api-push/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

The Push SDK for Aliyun OpenAPI
===============================

[](#the-push-sdk-for-aliyun-openapi)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ffe4b60f3bb131f0e401eac8616f95edaf26980afbcf279be40afaaa87b960ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f6b69656c73652f616c6979756e2d6f70656e2d6170692d707573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lokielse/aliyun-open-api-push)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/3e8bdb5d4ef1bab2b4be7a087c4f58cb1e5513f4e23c646e3481720a7ad8f72b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f6b69656c73652f616c6979756e2d6f70656e2d6170692d707573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lokielse/aliyun-open-api-push)

The Push SDK for Aliyun OpenAPI

Install
-------

[](#install)

Via Composer

```
$ composer require lokielse/aliyun-open-api-push
```

Usage
-----

[](#usage)

```
/**
 * 访问信息
 */
$config = [
	'AccessKeyId'=>'',
	'AccessKeySecret'=>'',
];

/**
 * 配置网关
 */
$endpoint = new Endpoint('cn-hangzhou', EndpointConfig::getRegionIds(), EndpointConfig::getProductDomains());
EndpointProvider::setEndpoints([ $endpoint ]);

/**
 * 授权资料
 */
$profile = DefaultProfile::getProfile('cn-hangzhou', $config['AccessKeyId'], $config['AccessKeySecret']);

/**
 * 请求对象
 */
$request = new \Aliyun\Push\Request\PushRequest();

/**
 * 推送目标
 */
$request->setAppKey($appKey);
$request->setTarget("all"); //推送目标: device:推送给设备; account:推送给指定帐号,tag:推送给自定义标签; all: 推送给全部
$request->setTargetValue("all"); //根据Target来设定，如Target=device, 则对应的值为 设备id1,设备id2. 多个值使用逗号分隔.(帐号与设备有一次最多100个的限制)
$request->setDeviceType(3); // 设备类型deviceType 取值范围为:0~3. iOS设备: 0; Android设备: 1; 全部: 3, 这是默认值.

/**
 * 推送配置
 */
$request->setType(1); // 0:表示消息(默认为0), 1:表示通知
$request->setTitle("Hello OpenAPI!"); // 消息的标题
$request->setBody("PushRequest body"); // 消息的内容
$request->setSummary("PushRequest summary"); // 通知的摘要

/**
 * 推送配置: iOS
 */
$request->setiOSBadge("5"); // iOS应用图标右上角角标
$request->setiOSMusic("default"); // iOS通知声音
$request->setiOSExtParameters("{\"k1\":\"ios\",\"k2\":\"v2\"}"); //自定义的kv结构,开发者扩展用 针对iOS设备
$request->setApnsEnv("DEV");
$request->setRemind("false"); // 当APP不在线时候，是否通过通知提醒

/**
 *  推送配置: Android
 */
$request->setAndroidOpenType("3"); // 点击通知后动作,1:打开应用 2: 打开应用Activity 3:打开 url
$request->setAndroidOpenUrl("http://www.baidu.com"); // Android收到推送后打开对应的url,仅仅当androidOpenType=3有效
$request->setAndroidExtParameters("{\"k1\":\"android\",\"k2\":\"v2\"}"); // 设定android类型设备通知的扩展属性

/**
 * 推送控制
 */
//$pushTime = new DateTime();
//$pushTime->add(new DateInterval('PT30S')); // 30秒之后的时间点, 也可以设置成你指定固定时间
//$request->setPushTime($pushTime->format('Y-m-d\TH:i:s\Z')); // 延后推送。可选，如果不设置表示立即推送
$request->setStoreOffline("false"); // 离线消息是否保存,若保存, 在推送时候，用户即使不在线，下一次上线则会收到
//$expireTime = new DateTime();
//$expireTime->add(new DateInterval('P1D')); // 12小时后消息失效, 不会再发送
//$request->setExpireTime($expireTime->format('Y-m-d\TH:i:s\Z'));
//$request->setBatchNumber("100010"); // 批次编号,用于活动效果统计. 设置成业务可以记录的字符串

$client   = new DefaultAcsClient($profile);
$response = $client->getAcsResponse($request);

var_dump($response);
```

[官方文档](https://help.aliyun.com/document_detail/30074.html)

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Lokielse](https://github.com/lokielse)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

3592d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc86898863e8b4ab04e11e787c662480a6ca08628df871ecfe8015e3277746b8?d=identicon)[waisir](/maintainers/waisir)

---

Top Contributors

[![lokielse](https://avatars.githubusercontent.com/u/1573211?v=4)](https://github.com/lokielse "lokielse (8 commits)")

---

Tags

phpsdkpushaliyun

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lokielse-aliyun-open-api-push/health.svg)

```
[![Health](https://phpackages.com/badges/lokielse-aliyun-open-api-push/health.svg)](https://phpackages.com/packages/lokielse-aliyun-open-api-push)
```

###  Alternatives

[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)

PHPackages © 2026

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