如何使用 PHP AWS SDK 请求 API Gateway 端点?
我有https://api-id.execute-api.region.amazonaws.com/stage
endpoint,如何使用SDK查询它?
找到ApigatewayClient
,但无法弄清楚如何正确使用它,并且在Internet上找不到任何有用的用法示例。
某些方法需要一些连接或其他参数,我相信应该有一种简单的方法。
编辑 例如,我的API URL是https://myawsomeid.execute-api.eu-central-central-1.amazonaws.com/prod/
其中“ myawsomeid”是我的apiid。 像这样查询它:
$this->client->getStage([
'restApiId' => 'myawesomeid',
'stageName' => 'execute-api',
]);
并遇到了这样的错误:
Error executing \"GetStage\" on \"https://apigateway.eu-central-1.amazonaws.com/restapis/myawesomeid/stages/execute-api\"; AWS HTTP error: Client error: `GET https://apigateway.eu-central-1.amazonaws.com/restapis/myawesomeid/stages/execute-api` resulted in a `403 Forbidden` response:\n{\"Message\":\"User: arn:aws:iam::804737862755:user/staging-api-s3-assets is not authorized to perform: apigateway:GET on r (truncated...)\n AccessDeniedException (client): User: arn:aws:iam::804737862755:user/staging-api-s3-assets is not authorized to perform: apigateway:GET on resource: arn:aws:apigateway:eu-central-1::/restapis/myawesomeid/stages/execute-api because no identity-based policy allows the apigateway:GET action - {\"Message\":\"User: arn:aws:iam::804737862755:user/staging-api-s3-assets is not authorized to perform: apigateway:GET on resource: arn:aws:apigateway:eu-central-1::/restapis/myawesomeid/stages/execute-api because no identity-based policy allows the apigateway:GET action\"}\n
我认为我可能没有足够的权限,但是使用Postman,我可以通过使用代码连接的凭据查询我的API端点。 我需要的只是使我的API获取/发布。我做错了吗?
I have https://api-id.execute-api.region.amazonaws.com/stage
endpoint, how to query it using SDK?
Found ApiGatewayClient
but can't figure out how to use it properly and didn't find any helpful usage examples on the internet.
Some methods require some ConnectionID or another arguments, I am sure there should be a simple way.
EDIT
For instance my Api url is https://myawesomeid.execute-api.eu-central-1.amazonaws.com/prod/
where "myawesomeid" is my ApiId.
Querying it like this:
$this->client->getStage([
'restApiId' => 'myawesomeid',
'stageName' => 'execute-api',
]);
And got such error:
Error executing \"GetStage\" on \"https://apigateway.eu-central-1.amazonaws.com/restapis/myawesomeid/stages/execute-api\"; AWS HTTP error: Client error: `GET https://apigateway.eu-central-1.amazonaws.com/restapis/myawesomeid/stages/execute-api` resulted in a `403 Forbidden` response:\n{\"Message\":\"User: arn:aws:iam::804737862755:user/staging-api-s3-assets is not authorized to perform: apigateway:GET on r (truncated...)\n AccessDeniedException (client): User: arn:aws:iam::804737862755:user/staging-api-s3-assets is not authorized to perform: apigateway:GET on resource: arn:aws:apigateway:eu-central-1::/restapis/myawesomeid/stages/execute-api because no identity-based policy allows the apigateway:GET action - {\"Message\":\"User: arn:aws:iam::804737862755:user/staging-api-s3-assets is not authorized to perform: apigateway:GET on resource: arn:aws:apigateway:eu-central-1::/restapis/myawesomeid/stages/execute-api because no identity-based policy allows the apigateway:GET action\"}\n
I think I might not have enough permissions, but using Postman I can query my Api endpoint by this credentials I use to connect via code.
What I need is just to make GET/POST to my API. Am I doing it wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您使用需要参数,然后调用正确的方法。例如 :
First you build client with needed parameters, then you call proper methods. E.g. getStage: