定制 net-tools/aws-ses-gui-notifications 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

net-tools/aws-ses-gui-notifications

最新稳定版本:1.0.11

Composer 安装命令:

composer require net-tools/aws-ses-gui-notifications

包简介

Composer library to query AWS SES notifications (SQS queues)

README 文档

README

PHP and Javascript interface to query AWS SES notifications

When using AWS SES, it's possible to set bounce and delivery feedback to be published through a SNS topic. When a SQS queue has subscribed to the SNS topic, it will contain any bounce or delivery messages created during SES send action.

This library abstracts most of AWS API-related stuff and deals with GUI output.

How to use

Client-side Javascript

First, include the javascript api.js.min file in the web page.

Then, create the API object and execute the request, providing any required parameters :

  • nodeId is a string set to a DOM tree element id value ; this element will contain the output
  • type is a string setting the kind of SES data we fetch : Delivery or Bounce
  • cssClass may be set with any CSS class names, making it possible to custom styling the output table
// creating API object
var req = new nettools.awsSesGuiNotifications(nodeId, type, cssClass);

// execute request and update GUI
req.update(
	// callback that must return a Promise object resolved with SQS data (see server-side remark below)
	function()
	{
		return fetch('/path/to/a/script.php', {
			method : 'POST'
		})
		.then(function(response){
			return response.json();
		});
	},

	// updates count (see remark below)
	5
);

Remarks :

  • SQS queues may not return all messages in a single API call ; so it's necessary to perform several request to be sure to have all data.
  • Create a server-side PHP file that will perform the AWS API call through our library and return the messages to the Javascript class.

Server-side PHP

The server-side PHP file (refered above as /path/to/a/script.php must call our API to send the request to AWS SQS :

// creating Request object
$rq = new \Nettools\AwsSesGuiNotifications\Request(\Aws\Credentials\CredentialProvider::ini('default', '/path/to/aws/credentials'), $region);

// perform API call ; set $url_of_sqs_queue with the correct URL of the SQS queue to be queried
$ret = $rq->execute($url_of_sqs_queue);

// answer with json data
header("Content-Type: application/json; charset=utf-8");
echo json_encode($ret);

Please note that the CredentialProvider::ini call must define a path to a credentials file, and that $region must be a string setting the correct AWS region.

The credentials file must contains the following lines, with your key and secrets :

[default]
aws_access_key_id = ___key_here___
aws_secret_access_key = ___secret_here___

统计信息

  • 总下载量: 39
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-22