Skip to content

Instantly share code, notes, and snippets.

@ivangonekrazy
Created November 1, 2012 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivangonekrazy/3990985 to your computer and use it in GitHub Desktop.
Save ivangonekrazy/3990985 to your computer and use it in GitHub Desktop.
Send events to Loggly from ActionScript
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