Created
November 1, 2012 01:09
-
-
Save ivangonekrazy/3990985 to your computer and use it in GitHub Desktop.
Send events to Loggly from ActionScript
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
import flash.net.URLLoader; | |
import flash.net.URLRequest; | |
import flash.net.URLRequestMethod; | |
import flash.net.URLVariables; | |
import flash.events.Event; | |
import flash.events.ErrorEvent; | |
import flash.events.IOErrorEvent; | |
import flash.events.SecurityErrorEvent; | |
public function sendEvent():void { | |
var url:String = "http://logs.loggly.com/inputs/"; | |
var token:String = "<your Loggly HTTP input token.>"; | |
var request:URLRequest = new URLRequest(url + token); | |
request.method = URLRequestMethod.POST; | |
request.data = "{\"message\": \"Hello from ActionScript!\"}"; | |
var requestor:URLLoader = new URLLoader(); | |
requestor.addEventListener( Event.COMPLETE, httpComplete ); | |
requestor.addEventListener( IOErrorEvent.IO_ERROR, httpFail ); | |
requestor.addEventListener( SecurityErrorEvent.SECURITY_ERROR, httpFail ); | |
requestor.load( request ); | |
} | |
private function httpComplete( event:Event ):void { | |
trace("Completed: " + event.message); | |
} | |
private function httpFail( error:ErrorEvent ):void { | |
trace("FAILED: " + error.message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment