Linux 软件免费装
Banner图

{eac}Doojigger Simple AWS Extension for WordPress

开发者 kevinburkholder
更新时间 2025年5月1日 18:36
PHP版本: 7.4 及以上
WordPress版本: 6.8
版权: GPLv3 or later
版权网址: 版权信息

标签

aws amazon web services S3 Bucket {eac}Doojigger AWS PHP SDK EventBridge

下载

1.0.2 1.0.1 1.0.4 1.1.0

详情介绍:

Simple AWS This extension, when enabled, provides easy access to Amazon Web Services (AWS) from other plugins, extensions and custom functions through the AWS SDK for PHP. From the settings page, enter your AWS Region and your IAM account credentials, then access AWS programmatically using the provided methods and filters along with the AWS SDK classes and methods. Please review: Available Methods getAwsRegion() returns your selected region getAwsAccessKey() returns your access key getAwsAccessSecret() returns your access secret getAwsCredentials() returns a 'credentials' array with your key and secret getAwsClientParams() returns an AWS client instantiation array getAwsEndpoints() returns a (large) array of all AWS endpoint parameters getAwsRegions() returns an array of all regions (name=>description) setAwsVersion() override default ('latest') version setAwsRegion() override set region setAwsEndPoint() override default endpoint Available Filters SimpleAWS_version returns the AWS version string SimpleAWS_region returns your selected region SimpleAWS_access_key returns your access key SimpleAWS_access_secret returns your access secret SimpleAWS_credentials returns a 'credentials' array with your key and secret SimpleAWS_client_params returns an AWS client instantiation array SimpleAWS_endpoints returns a (large) array of all AWS endpoint parameters SimpleAWS_regions returns an array of all regions (name=>description) Examples ```php $cloudFront = new Aws\CloudFront\CloudFrontClient([ 'version' => 'latest', 'region' => apply_filters('SimpleAWS_region',''), 'credentials' => [ 'key' => apply_filters('SimpleAWS_access_key',''), 'secret' => apply_filters('SimpleAWS_access_secret','') ] ]); if ($aws = $this->getExtension('Simple_AWS')) { $cloudFront = new Aws\CloudFront\CloudFrontClient([ 'version' => 'latest', 'region' => $aws->getAwsRegion(), 'credentials' => $aws->getAwsCredentials(), ]); } if ($aws = eacDoojigger()->getExtension('Simple_AWS')) { $cloudFront = new Aws\CloudFront\CloudFrontClient([ 'version' => $aws->getAwsVersion(), 'region' => $aws->getAwsRegion(), 'credentials' => $aws->getAwsCredentials(), ]); } if ($aws = $this->getExtension('Simple_AWS')) { $cloudFront = new Aws\CloudFront\CloudFrontClient( $aws->getAwsClientParams() ); } if ($aws = eacDoojigger()->getExtension('Simple_AWS')) { $cloudFront = new Aws\CloudFront\CloudFrontClient( $aws->getAwsClientParams() ); } if ($aws = $this->plugin->getExtension('Simple_AWS')) { if ($awsParams = $aws->getAwsClientParams()) { try { $s3client = new \Aws\S3\S3Client($awsParams); $result = $s3client->createBucket([ 'Bucket' => $bucketName, ]); $result = $s3client->putObject([ 'Bucket' => $bucketName, 'Key' => $fileName, 'Metadata' => $metadata, 'Body' => json_encode($payload,JSON_PRETTY_PRINT), ]); } catch (\AwsException $exception) { $this->logError($exception,"AWS S3Client Error"); } } } ``` Simple AWS S3 Events The Simple AWS S3 Events extension is intended to facilitate events through AWS EventBridge, passing data from and to WordPress/WooCommerce ... but you may find other uses.
  1. A webhook delivery URL is created to be used by WooCommerce to send data (order, product, or coupon) as a file to an AWS S3 bucket.
  2. An EventBridge Target URL is created to accepts data from AWS EventBridge derived from the file saved to the S3 bucket.
These 2 features may be used by the same WordPress installation (though I'm not sure why) or by different, even several, installations to route WooCommerce data to other destinations. For example: Site1 \ / EventBridge Target -> Site5 Site2 -> - WC Webhook Delivery -> [ Site4 ] -> - S3 Bucket -> EventBridge Target -> Site6 Site3 / \ EventBridge Target -> Site7 One or many WooCommerce sites can use the WebHook Delivery URL of another site to send orders through that site and then on to an S3 bucket as individual files. EventBridge can be configured to deliver S3 files to one (or many) WordPress sites using the EventBridge Target URL. This extension creates the APIs and formats the data to be sent to or received from AWS. To process data beyond what this extension does, you may use any of these actions: ```php /* * action eventbridge * @param object $file - S3 file object ($file->get('Body') to get contents) * @param array $meta - EventBridge API metadata * @param string $type - object type (order|product|coupon) * @param string $name - object file name / add_action( "eacDoojigger_eventbridge_object", 'my_eventbridge_action', 10, 4 ); add_action( "eacDoojigger_eventbridge_order", 'my_eventbridge_action', 10, 4 ); add_action( "eacDoojigger_eventbridge_product", 'my_eventbridge_action', 10, 4 ); add_action( "eacDoojigger_eventbridge_coupon", 'my_eventbridge_action', 10, 4 ); function my_EventBridge_action($file, $payload, $type, $fileName) { $data = $file->get('Body'); } ``` WooCommerce Setup WooCommerce Webhooks can be added for Orders, Products, or Coupons. When creating a new webhook (WooCommerce -> Settings -> Advanced -> Webhooks) use the Webhook Delivery URL and Webhook Secret provided by this extension. S3 Setup This extension, by default, creates a new S3 bucket named wc-webhook-<your-site-name>. To override this or use an existing bucket... php add_action( "eacDoojigger_eventbridge_bucketname", function($bucketName) { return 'my-s3-bucket'; } ); S3 bucket filenames are wc_<order|product|coupon>_##.json, e.g. wc_order_300.json. To override the file name used... php add_action( "eacDoojigger_eventbridge_filename", function($fileName, $objectType, $objectId) { return 'my_s3_' . $objectType . '_' . $objectId . '.json'; },10,3 ); When changing the bucket name and/or file name, the Event pattern shown below will also have to be changed. EventBridge Setup There are several steps and configurations needed to get EventBridge working properly. Below are the key components needed for proper configuration, other options may be set to your preferences/needs. In AWS EventBridge:
  1. EventBridge -> Connections -> Create Connection
  2. API type: Public
  3. Authorization type: Basic
  4. Username: a WordPress user
  5. Password: the application password for the user
alternatively json { "detail": { "bucket": { "name": [{ "prefix": "wc-webhook-" }] }, "object": { "key": [{ "prefix": "wc_order_" }] } } } + Target 1, Target types: EventBridge API destination + API destination: Use an existing API destination (select the API destination created in step 2) You can add other targets, such as CloudWatch for logging, other WordPress sites using this extension, or other services that can ingest this data. This extension provides logging (debug level) to expose detailed data structures. See also: How do I create and troubleshoot an Amazon EventBridge rule that triggers on S3 objects or operations? on AWS re:Post. Using AWS CloudFront or Simple Email Service

安装:

{eac}SimpleAWS is an extension plugin to and requires installation and registration of {eac}Doojigger. Automatic Plugin Installation This plugin is available from the WordPress Plugin Repository and can be installed from the WordPress Dashboard » Plugins » Add New page. Search for 'EarthAsylum', click the plugin's [Install] button and, once installed, click [Activate]. See Managing Plugins -> Automatic Plugin Installation Upload via WordPress Dashboard Installation of this plugin can be managed from the WordPress Dashboard » Plugins » Add New page. Click the [Upload Plugin] button, then select the eacsimpleaws.zip file from your computer. See Managing Plugins -> Upload via WordPress Admin Manual Plugin Installation You can install the plugin manually by extracting the eacsimpleaws.zip file and uploading the 'eacsimpleaws' folder to the 'wp-content/plugins' folder on your WordPress server. See Managing Plugins -> Manual Plugin Installation Settings Once installed and activated options for this extension will show in the 'AWS' tab of {eac}Doojigger settings.

屏幕截图:

  • Simple AWS Help

其他记录:

Additional Information {eac}SimpleAWS is an extension plugin to and requires installation and registration of {eac}Doojigger. See Also:

更新日志:

Version 1.1.0 – Apr 29, 2025 Version 1.0.3 – Apr 19, 2025 Version 1.0.2 – April 10, 2024 Version 1.0.1 – September 9, 2023 Version 1.0.0 – June 3, 2023