我从拉拉维尔8号迁移到拉力维尔8+辛烷/斯沃尔。所有的功能都很好,但是php://input总是空的。此外,我检查$_POST和$_SERVER值。
file_get_contents('php://input')由AWS SNS消息验证器使用。
任何阅读php://input的选择
PHP代码
echo "php://input: ".file_get_contents('php://input');使用
$ curl -i -X POST --data "dataaaa" https://example.com/aws/sns/webhook
php://input: dataaaa用Octane+Swoole
$ curl -i -X POST --data "dataaaa" https://example.com/aws/sns/webhook
php://input:发布于 2021-07-29 21:33:10
问题
php://input在Swoole上不可用。始终是相同的运行过程。
解决方案: PSR-7请求
use Psr\Http\Message\RequestInterface;
public function sesSubscriptionWebhook(RequestInterface $request)
{
// $input = file_get_contents('php://input'); // dont work on swoole
$input = $request->getBody();
}当然,与辛烷,symfony/psr-http-message-bridge和nyholm/psr7是Laravel PSR-7请求的要求。
此外,如果您的问题与AWS 相关,则需要将Message::fromRawPostData()更改为Message::fromPsrRequest($request)。
https://stackoverflow.com/questions/68582378
复制相似问题