I’m trying to use cover art archive api. Cover Art Archive
var request:URLRequest = new URLRequest();
request.url = "http://coverartarchive.org/release/76df3287-6cda-33eb-8e9a-044b5e15ffdd/";
request.method = URLRequestMethod.GET;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, loaderComplete);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(request);
function loaderComplete(evt:Event):void {
trace("Load Succcsed");
}
function ioErrorHandler(evt:IOErrorEvent):void {
trace("io: " + evt + "\n");
}
function httpStatusHandler(evt:HTTPStatusEvent):void {
trace("status: " + evt + "\n");
}
but all I get is:
status: [HTTPStatusEvent type=”httpStatus” bubbles=false cancelable=false eventPhase=2 status=0 responseURL=null]
io: [IOErrorEvent type=”ioError” bubbles=false cancelable=false eventPhase=2 text=”Error #2032: Stream Error. URL: http://coverartarchive.org/release/76df3287-6cda-33eb-8e9a-044b5e15ffdd/“]
anyone can tell me what am I doing wrong?
Thx
edit 1: add:
reqest.requestHeaders = new Array(new URLRequestHeader(“accept”, “application/json”));
still no go…
I don’t think you are doing anything wrong. It seems like the HTTP request returns with a
307 TEMPORARY REDIRECTstatus :AFAIK, Flash
URLLoader/URLRequestis not able to handle redirection for you ; the only solution I see is to issue HTTP requests by yourself using theSocketclass, and grap theLocationyourself! Obviously someone already tried it.