craigh/alexa-request-validator
Composer 安装命令:
composer require craigh/alexa-request-validator
包简介
Validates requests from Amazon Alexa
README 文档
README
A PHP implementation of the Alexa request validation required when using a web service with your Alexa skill, as set out in the Alexa docs
Installation
Install via composer by doing:
composer require craigh/alexa-request-validator
How to use
Once installed you can instantiate the AlexaRequestValidator in your classes as follows:
$validator = new \Humps\AlexaRequest\AlexaRequestValidator('YOUR_ALEXA_SKILL_ID', file_get_contents('php://input'), $_SERVER['HTTP_SIGNATURECERTCHAINURL'], $_SERVER['HTTP_SIGNATURE']);
Then simply do (Ideally you would add this in Middleware):
try { if($validator->validateRequest()){ // Accept request to your service } // Reject request with a 500 error, hopefully this shouldn't happen! }catch(\Humps\AlexaRequest\Exceptions\AlexaValidationException $e) { // Reject the request with a 400 error or the given error code (via $e->getCode()) with the returned message ($e->getMessage()) }
Timeout Tolerance
By default the timeout tolerance is 120 seconds (well within the 150 seconds required by Amazon). If you want to adjust this you can pass a fifth paramater to the constructor:
$validator = new AlexaRequestValidator('YOUR_ALEXA_SKILL_ID', file_get_contents('php://input'), $_SERVER['HTTP_SIGNATURECERTCHAINURL'], $_SERVER['HTTP_SIGNATURE'], 150);
Tip: If you are testing through the Amazon Alexa Skill "test" section you may want to increase this tolerance during development so you can replay the request through your server. Just don't forget to reset it before certification!
craigh/alexa-request-validator 适用场景与选型建议
craigh/alexa-request-validator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.41k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2017 年 09 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 craigh/alexa-request-validator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 craigh/alexa-request-validator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12.41k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-09-25