Last active
December 11, 2015 20:39
-
-
Save raimonds1503/4656909 to your computer and use it in GitHub Desktop.
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
package draugiem | |
{ | |
import flash.display.Sprite; | |
import flash.events.Event; | |
import flash.events.EventDispatcher; | |
import flash.events.HTTPStatusEvent; | |
import flash.net.URLLoader; | |
import flash.net.URLRequest; | |
/** | |
* ... | |
* @author Raimonds Zarins | |
*/ | |
public class DraugiemApi | |
{ | |
public var apiKey:String; | |
public var uid:String; | |
public var user:Object; | |
private var loader:URLLoader; | |
public function DraugiemApi() | |
{ | |
} | |
public function authorize(auth_code:String):void | |
{ | |
loader = new URLLoader(); | |
var url:String = "http://api.draugiem.lv/xml/?action=authorize&app=" + GC.DRAUGIEM_API + "&code=" + auth_code; | |
DebugConsole.log("Requesting data from Draugiem.lv on url: " + url); | |
var request:URLRequest = new URLRequest(url); | |
loader.addEventListener(Event.COMPLETE , onAuthorize); | |
loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, onHttpDebug); | |
loader.load(request); | |
} | |
private function onHttpDebug(e:HTTPStatusEvent):void | |
{ | |
DebugConsole.log("HTTP:"); | |
DebugConsole.log(e.status); | |
} | |
private function onAuthorize(e:Event):void | |
{ | |
trace(e.target.data); | |
DebugConsole.log("Data received:"); | |
DebugConsole.log(e.target.data.users.user.name); | |
} | |
} | |
} |
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
package | |
{ | |
import draugiem.DraugiemApi; | |
import flash.display.Sprite; | |
import flash.events.Event; | |
import flash.text.TextField; | |
import net.flashpunk.Engine; | |
import net.flashpunk.FP; | |
import playerio.BigDB; | |
import Playtomic.Log; | |
/** | |
* ... | |
* @author Raimonds Zarins | |
*/ | |
public class Main extends Engine | |
{ | |
public function Main():void | |
{ | |
super(980, 500, 60, false); | |
GV.frype_auth_code = this.loaderInfo.parameters.dr_auth_code; | |
DebugConsole.log("Draugiem auth code: " + GV.frype_auth_code); | |
if (GV.frype_auth_code) | |
{ | |
//Log.View(GC.PLAYTOMIC_ID, GC.PLAYTOMIC_GUID, GC.PLAYTOMIC_API); | |
DebugConsole.log("Running in Draugiem.lv environment!"); | |
FP.console.enable(); | |
GV.frype = new DraugiemApi(); | |
GV.frype.authorize(GV.frype_auth_code); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment