Last active
February 8, 2016 14:27
-
-
Save YuukiOgino/78f66c2b6028845a15cf to your computer and use it in GitHub Desktop.
FlashからChatWorkにメッセージを投稿 ref: http://qiita.com/YuukiOgino/items/d350253670b9b5f73208
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static const CHATWORK_TOKEN:String = "ここにAPIトークンを記述します。"; | |
public static const ROOM_ID:String = "ここに投稿したいチャットのIDを記述します"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var url:String = "https://api.chatwork.com/v1/rooms/" + ROOM_ID + "/messages"; | |
var request:URLRequest = new URLRequest(url); | |
// 必ず一番初めにAPIトークンをセットすること | |
request.requestHeaders = [new URLRequestHeader("X-ChatWorkToken", CHATWORK_TOKEN)]; | |
request.method = URLRequestMethod.POST; | |
// 投稿する内容を記載 | |
var urlVariables:URLVariables = new URLVariables("body=Test"); | |
request.data = urlVariables; | |
var urlLoader:URLLoader = new URLLoader(); | |
urlLoader.addEventListener( Event.COMPLETE, httpRequestComplete ); | |
urlLoader.addEventListener( IOErrorEvent.IO_ERROR, httpRequestError ); | |
// 成功すれば投稿完了 | |
urlLoader.load(request); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment