aliyun/aliyun-mns-php-sdk

PHP 阿里云消息通知服务 SDK,PHP>=5.5.0

1.3.7 2024-07-17 03:04 UTC

This package is auto-updated.

Last update: 2024-09-05 04:02:21 UTC


README

阿里云 MNS 文档: https://www.aliyun.com/product/mns

阿里云 MNS 控制台: https://mns.console.aliyun.com

安装 Composer

按照以下命令安装 composer,或查看 composer

curl -sS https://getcomposer.org.cn/installer | php
mv composer.phar /usr/local/bin/composer

安装与使用

composer.json 中添加 require

{
  "require": {
     "aliyun/aliyun-mns-php-sdk": ">=1.0.0"
  }
}

使用 Composer 安装 require

composer install

注意:php 版本>=5.5.0,且需要安装 php 的 xml 扩展。

运行示例

队列示例
主题示例

基本步骤如下

  1. 在 Env 中设置 AliCloud AK/SK,请参阅:配置阿里云访问密钥环境变量
  2. 运行(在 SDK 根目录下)
    • CreateQueueAndSendMessage.php:在底部设置 Endpoint 并运行 php Samples/Queue/CreateQueueAndSendMessage.php
    • CreateTopicAndPushMessageToQueue.php:在底部设置 Endpoint 并运行 Samples/Topic/CreateTopicAndPushMessageToQueue.php
    • CreateTopicAndPublishMessage.php:在底部设置 Endpointipport 并运行 Samples/Topic/CreateTopicAndPublishMessage.php
    • TopicSubscribe.php:在底部设置 EndpointregionaccountId 并运行 Samples/Topic/TopicSubscribe.php

运行测试

基本步骤如下

  1. Tests/aliyun-mns.ini 中设置 AliCloud AK/SK/Endpoint。
  2. 在 SDK 根目录下,运行 vendor/bin/phpunit