我正在尝试使用封面艺术档案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");
}
但我得到的只是:
状态:[HTTPStatusEvent type =“httpStatus”bubbles = false cancelable = false eventPhase = 2 status = 0 responseURL = null]
io:[IOErrorEvent type =“ioError”bubbles = false cancelable = false eventPhase = 2 text =“错误#2032:流错误.URL:http://coverartarchive.org/release/76df3287-6cda-33eb-8e9a-044b5e15ffdd/”]
任何人都可以告诉我,我做错了什么?
THX
编辑1:添加: reqest.requestHeaders = new Array(new URLRequestHeader(“accept”,“application / json”)); 仍然没有去......
答案 0 :(得分:1)
我认为你做错了什么。似乎HTTP请求返回307 TEMPORARY REDIRECT
状态:
$ curl -v http://coverartarchive.org/release/76df3287-6cda-33eb-8e9a-044b5e15ffdd/
* About to connect() to coverartarchive.org port 80 (#0)
* Trying 72.29.166.157... connected
* Connected to coverartarchive.org (72.29.166.157) port 80 (#0)
> GET /release/76df3287-6cda-33eb-8e9a-044b5e15ffdd/ HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: coverartarchive.org
> Accept: */*
>
< HTTP/1.1 307 TEMPORARY REDIRECT
< Date: Sun, 20 Jan 2013 21:09:02 GMT
< Content-Type: text/plain; charset=utf-8
< Connection: keep-alive
< Keep-Alive: timeout=20
< Content-Length: 86
< Location: http://archive.org/download/mbid-76df3287-6cda-33eb-8e9a-044b5e15ffdd/index.json
< Access-Control-Allow-Origin: *
< Server: CherryPy/3.1.2 WSGI Server
<
See: http://archive.org/download/mbid-76df3287-6cda-33eb-8e9a-044b5e15ffdd/index.json
* Connection #0 to host coverartarchive.org left intact
* Closing connection #0
AFAIK,Flash URLLoader/URLRequest
无法为您处理重定向;我看到的唯一解决方案是使用Socket
类自己发出HTTP请求,并自己抓取Location
! Obviously someone already tried it
答案 1 :(得分:0)