动作3:读取RSS订阅源要求身份验证 [英] Actionscript 3: Reading an RSS feed that requires authentication
问题描述
我有我需要阅读的RSS源,但你需要有一个有效的用户名和密码来获取饲料登录。我想知道是否或如何做到这一点使用ActionScript 3。
I have an RSS feed that I need to read, but you need to log in with a valid username and password to get the feed. I was wondering if or how to do this using Actionscript 3.
现在我有一个刚刚得到的xml从提供的网址,并输出XML到控制台非常简单的脚本。
Right now I have a very simple script that just gets the xml from a provided url and outputs the xml to the console.
我已经验证了它与饲料不需要身份验证。
I've verified that it works with a feed that doesn't require authentication.
让我知道,如果code或任何更具体的是必要的。
Let me know if code or anything more specific is needed.
在此先感谢!
推荐答案
如果您使用的是HTTP服务,您可以通过扩展的HTTPService做基本授权:
If you're using an http service, you can do basic authorization with by extending the HTTPService :
package{
import mx.rpc.AsyncToken;
import mx.rpc.http.mxml.HTTPService;
import mx.utils.Base64Encoder;
public class HTTPServiceAuth extends HTTPService
{
public var username : String = '';
public var password : String = '';
public function HTTPServiceAuth(rootURL:String=null, destination:String=null)
{
super(rootURL, destination);
}
override public function send(parameters:Object=null ):AsyncToken {
var enc : Base64Encoder = new Base64Encoder();
enc.insertNewLines = false;
enc.encode(username + ':' + password );
this.headers = {Authorization:"Basic " + enc.toString())};
super.send(parameters);
}
}
}
您用同样的方式除了可以指定用户名和密码:
You use it the same way except you can specify a username and password :
<local:HTTPServiceAuth url="http://www.domain.com/feed/etc" username="myUsername" password="myPassword" ...rest of standard args, etc... />
这篇关于动作3:读取RSS订阅源要求身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!