chrisbarr / amazonsns-php-api Goto Github PK
View Code? Open in Web Editor NEWA lightweight PHP wrapper for the Amazon SNS API
Home Page: http://aws.amazon.com/sns/
License: MIT License
A lightweight PHP wrapper for the Amazon SNS API
Home Page: http://aws.amazon.com/sns/
License: MIT License
Upon unsubscribe, you need the subscriptionArn which is returned by AmazonSNS upon subscribe. If you return true, the subscriptionArn cannot be saved and thus the Endpoint cannot be unsubscribed afterwards
I've been using this library for a while. But I now have the requirement to connect to a Dockerised local version of SNS (rather than the real live AWS service).
Obviously, it's impossible with this library because the endpoints are derived from the region in the constructor. I'm currently working on adapting this library so the constructor will look like this:
public function __construct(string $accessKey, string $secretKey, string $endpoint) {
I will then provide a factory method to construct the client using a region:
public static function fromAwsCredentials(string $accessKey, string $secretKey, string $region): AmazonSNS {
This method would then encapsulate the logic of converting the region into an endpoint. I'd probably also inject the functionality of converting the region into an endpoint using a RegionHandler
class or something so that users can create their own providers (for handling new regions or whatever).
Obviously this is making a breaking change and is almost become another library altogether. But I will keep your _request
method and all the API methods themselves intact.
So my question is, do you want me to do a PR for all of this? And make it a new major version? Or would you rather I just created my own GitHub/Packagist for this and go our separate ways?
I have a progrma in the format of this and I am getting this error There was a problem executing this request. Could you halp me understand the problem.
// Create an instance
$AmazonSNS = new AmazonSNS('key', 'key');
$AmazonSNS->setRegion('us-east-1');
// And send a message to subscribers of this topic
$AmazonSNS->publish(topicarn', $message);
Not sure why, but on one of our servers http_build_query() function was separating URL parameters with &s; instead of &.
Changing line to this solved the issue.
$request = $this->protocol . $this->endpoint . '/?' . http_build_query($params,'','&');
Second issue I found was that the Timestamp should include milliseconds:
$params['Timestamp'] = gmdate('Y-m-d\TH:i:s.000\Z');
Otherwhise great class. I love these simple single purpose classes instead of large SDKs.
I have a requirement to send a SMS to individual mobile numbers but you have written only for topicARN.
Run your sample code, got this error:
Fatal error: Uncaught exception 'APIException' with message 'There was a problem executing this request' in /Applications/XAMPP/xamppfiles/htdocs/dummyserver/vendor/chrisbarr/amazon-sns-php-api/lib/AmazonSNS.php:567 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/dummyserver/vendor/chrisbarr/amazon-sns-php-api/lib/AmazonSNS.php(177): AmazonSNS->_request('CreateTopic', Array) #1 /Applications/XAMPP/xamppfiles/htdocs/dummyserver/server1/sns.php(9): AmazonSNS->createTopic('My New SNS Topi...') #2 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/dummyserver/vendor/chrisbarr/amazon-sns-php-api/lib/AmazonSNS.php on line 567
Im currently working on a plugin for my mail list system, that got to handle bounces, the problem right now, is im not 100% sure how to access and pull out thos items from SNS.
Can you give me a small hint?
if(isset($resultXml->ListSubscriptionsResult->NextToken)) {
$return->nexttoken = $resultXml->ListSubscriptionsResult->NextToken;
}
$return->members = $this->_processXmlToArray($subs);
return $return;
Something goes wrong in the Signature creation... Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.