chrisbarr/amazon-sns-php-api
Composer 安装命令:
composer require chrisbarr/amazon-sns-php-api
包简介
Amazon SNS PHP API
README 文档
README
This API wrapper is a lightweight alternative to the official Amazon aws-sdk-for-php for access to Amazon SNS (Simple Notification Service) using PHP
Find out more about Amazon SNS here - http://aws.amazon.com/sns
To use this wrapper you must be using PHP5 with cURL, and have an Amazon AWS account
Basic Use
Install using Composer on the command line:
$ composer require chrisbarr/amazon-sns-php-api
Or add it to your composer.json file:
{
...
"require": {
"chrisbarr/amazon-sns-php-api": "~1.0"
}
}
Example usage:
<?php require 'vendor/autoload.php'; // Create an instance $AmazonSNS = new AmazonSNS(AMAZON_ACCESS_KEY_ID, AMAZON_SECRET_ACCESS_KEY); // Create a Topic $topicArn = $AmazonSNS->createTopic('My New SNS Topic'); // Set the Topic's Display Name (required) $AmazonSNS->setTopicAttributes($topicArn, 'DisplayName', 'My SNS Topic Display Name'); // Subscribe to this topic $AmazonSNS->subscribe($topicArn, 'email', 'example@github.com'); // And send a message to subscribers of this topic $AmazonSNS->publish($topicArn, 'Hello, world!');
API Methods
Available methods:
addPermission($topicArn, $label, $permissions)confirmSubscription($topicArn, $token)createTopic($name)deleteTopic($topicArn)getTopicAttributes($topicArn)listSubscriptions()listSubscriptionsByTopic($topicArn)listTopics()publish($topicArn, $message, $subject, $messageStructure)removePermission($topicArn, $label)setTopicAttributes($topicArn, $attrName, $attrValue)subscribe($topicArn, $protocol, $endpoint)unsubscribe($subscriptionArn)createPlatformEndpoint($platformApplicationArn, $token, $userData)deleteEndpoint($deviceArn)publishToEndpoint($deviceArn,$message)
To set the API region (us-east-1, us-west-2, us-west-1, eu-west-1, etc):
setRegion($region)
The default API region is us-east-1
Further Example
Make sure to catch Exceptions where necessary:
<?php require 'vendor/autoload.php'; $AmazonSNS = new AmazonSNS(AMAZON_ACCESS_KEY_ID, AMAZON_SECRET_ACCESS_KEY); $AmazonSNS->setRegion('eu-west-1'); try { $topics = $AmazonSNS->listTopics(); } catch(SNSException $e) { // Amazon SNS returned an error echo 'SNS returned the error "' . $e->getMessage() . '" and code ' . $e->getCode(); } catch(APIException $e) { // Problem with the API echo 'There was an unknown problem with the API, returned code ' . $e->getCode(); }
chrisbarr/amazon-sns-php-api 适用场景与选型建议
chrisbarr/amazon-sns-php-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 228.58k 次下载、GitHub Stars 达 68, 最近一次更新时间为 2015 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「amazon」 「aws」 「SNS」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 chrisbarr/amazon-sns-php-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chrisbarr/amazon-sns-php-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 chrisbarr/amazon-sns-php-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
A Laravel artisan based package to create the AWS (SES + SNS) infrastructure to receive email event notifications with Http/Https endpoint.
Elastic Driver for Laravel Scout
Laravel package to push events to AWS SNS
simple api library.
Laravel Broadcasting SNS
统计信息
- 总下载量: 228.58k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 69
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-04