LoginSignup
0
0

More than 5 years have passed since last update.

ActionScript3でAWS API Gatewayと通信

Posted at

そのものズバリをコピペで動くように。
API GatewayはPOSTにしておくとラク:relaxed:
API_URL と API_KEY に、API Gatewayから払い出されたデプロイURLとAPIキーを代入しておく。
APIキーは、AWSのコンソールから、API Gateway内にある使用量プランの設定を忘れないように。

// API_URL API GatewayからデプロイされたURL
// API_KEY API Gatewayから発行されたAPIキー
// data    任意の値。Object型
var request:URLRequest = new URLRequest(API_URL);
request.method = URLRequestMethod.POST;
request.requestHeaders.push(new URLRequestHeader('x-api-key', API_KEY));
request.data = JSON.stringify(data);

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, function(event:Event){
  trace('complete');
});
loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, function(event:HTTPStatusEvent):void{
  trace('status');
});
loader.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void{
  trace('token register error.');
});
loader.load(request);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0