【Amazon connect】初使用(含php调用代码)实现电话通知告警

公司的报警系统希望接入amazon connect,希望在重大事故发生的时候,能直接打电话通知运维,及时处理。
网上amazon connect例子不多,在这简单记录,仅供参考。附php代码

主要参考了以下博客:

官方的博客:https://aws.amazon.com/cn/blogs/china/use-amazon-connect-cloudwatch-realize-call-notification-cloud-alarm/
网上找的:https://figaroskingdom.com/placing-outbound-calls-using-amazon-connect-api-php/
官方用户操作文档:https://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/tutorial1-set-up-your-instance.html
官方SDK for PHP:https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-Aws.Connect.ConnectClient.html
官方定价(里面能看到支持的地区或国家):https://aws.amazon.com/cn/connect/pricing//mermaidjs.github.io/)

大致步骤:

1、配置实例
2、创建联系流
3、在代码里调用API

一、进入到amazon connect服务页面

在这里插入图片描述

二、创建实例 可参照https://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/tutorial1-set-up-your-instance.html里左侧菜单栏里的“教程”

在这里插入图片描述
名称可随意
在这里插入图片描述
管理员信息都填写一下
在这里插入图片描述
我主要用来出站呼叫,两个都勾选也没关系
在这里插入图片描述
一些数据存储路径,我直接点了下一步
在这里插入图片描述
点创建实例就好了
在这里插入图片描述
这里可以看到实例ID,后面代码调用API的时候会用到,斜杠后面那一串就是了
在这里插入图片描述

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是使用 PHP 生成 Amazon使用 putListingsItem 上传产品的代码示例: ```php <?php // 设置 AWS 访问密钥和卖家 ID define('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY_ID'); define('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_ACCESS_KEY'); define('MERCHANT_ID', 'YOUR_MERCHANT_ID'); // 设置产品信息 $product = array( 'sku' => 'YOUR_SKU', 'title' => 'YOUR_PRODUCT_TITLE', 'description' => 'YOUR_PRODUCT_DESCRIPTION', 'price' => 'YOUR_PRODUCT_PRICE', 'quantity' => 'YOUR_PRODUCT_QUANTITY', 'condition' => 'YOUR_PRODUCT_CONDITION', 'image' => 'YOUR_PRODUCT_IMAGE_URL', 'category' => 'YOUR_PRODUCT_CATEGORY', ); // 生成 XML 数据 $xml = '<?xml version="1.0" encoding="utf-8"?> <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.01</DocumentVersion> <MerchantIdentifier>'.MERCHANT_ID.'</MerchantIdentifier> </Header> <MessageType>Product</MessageType> <PurgeAndReplace>false</PurgeAndReplace> <Message> <MessageID>1</MessageID> <OperationType>Update</OperationType> <Product> <SKU>'.$product['sku'].'</SKU> <StandardProductID> <Type>ASIN</Type> <Value>'.$product['asin'].'</Value> </StandardProductID> <ProductTaxCode>A_GEN_NOTAX</ProductTaxCode> <DescriptionData> <Title>'.$product['title'].'</Title> <Brand>'.$product['brand'].'</Brand> <Description>'.$product['description'].'</Description> <BulletPoint>'.$product['bullet_point_1'].'</BulletPoint> <BulletPoint>'.$product['bullet_point_2'].'</BulletPoint> <BulletPoint>'.$product['bullet_point_3'].'</BulletPoint> <BulletPoint>'.$product['bullet_point_4'].'</BulletPoint> <BulletPoint>'.$product['bullet_point_5'].'</BulletPoint> <MSRP currency="USD">'.$product['msrp'].'</MSRP> <Manufacturer>'.$product['manufacturer'].'</Manufacturer> <ItemType>'.$product['item_type'].'</ItemType> </DescriptionData> <ProductData> <Health> <ProductType> <HealthMisc> <Ingredients>'.$product['ingredients'].'</Ingredients> </HealthMisc> </ProductType> </Health> </ProductData> </Product> </Message> </AmazonEnvelope>'; // 设置请求参数 $params = array( 'AWSAccessKeyId' => AWS_ACCESS_KEY_ID, 'Action' => 'SubmitFeed', 'Merchant' => MERCHANT_ID, 'SignatureMethod' => 'HmacSHA256', 'SignatureVersion' => '2', 'Timestamp' => gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time()), 'Version' => '2009-01-01', 'FeedType' => '_POST_PRODUCT_DATA_', 'ContentMD5Value' => base64_encode(md5($xml, true)), ); // 生成签名字符串 ksort($params); $pairs = array(); foreach ($params as $key => $value) { array_push($pairs, rawurlencode($key).'='.rawurlencode($value)); } $canonical_query_string = join('&', $pairs); $string_to_sign = "POST\nmws.amazonservices.com\n/Feeds/2009-01-01\n".$canonical_query_string; $signature = rawurlencode(base64_encode(hash_hmac('sha256', $string_to_sign, AWS_SECRET_ACCESS_KEY, true))); // 发送请求 $url = "https://mws.amazonservices.com/Feeds/2009-01-01?".$canonical_query_string."&Signature=".$signature; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // 处理响应结果 if ($status == 200) { $xml_response = simplexml_load_string($response); if ($xml_response->MessageID) { echo "Product uploaded successfully: ".$xml_response->MessageID; } else { echo "Product upload failed"; } } else { echo "Error uploading product: ".$response; } ?> ``` 请注意,上述代码仅供参考,需要根据您的实际情况进行修改。同时,您也需要确保您的服务器已经被授权访问 Amazon MWS API,并且您已经在 Amazon 开发者中心注册了您的应用程序。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值