作为我正在构建的移动应用程序的一部分,我必须通过 Last.FM 的 API 进行身份验证。正如他们网站上记录的那样,我尝试正确格式化为 url,但显然我做错了,因为我收到错误:
错误 #2044:未处理的 ioError:。文本=错误 #2032:流错误。网址:https ://ws.audioscrobbler.com/2.0/?method=auth.getMobileSession
Last.FM 文档:http ://www.last.fm/api/mobileauth
我的代码如下:
var username:String = "xxxxxxx";
var password:String = "xxxxxxxxxxxx";
var api_key:String = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
var secret:String = "xxxxxxxxxxxxxxxxxxxxxx";
var api_sig:String = MD5.hash( "api_key" + api_key + "methodauth.getMobileSessionpassword" + password + "username" + secret);
var request:URLRequest = new URLRequest("https://ws.audioscrobbler.com/2.0/?method=auth.getMobileSession");
var variables:URLVariables = new URLVariables();//create a variable container
variables.username =username;
variables.password = password;
variables.api_key = api_key;
variables.api_sig = api_sig;
request.data = variables;
request.method = URLRequestMethod.POST;//select the method as post/
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, handleComplete);
loader.load(request);//send the request with URLLoader()
有人知道答案吗?