Quantcast
Viewing all articles
Browse latest Browse all 2

Answer by Nate for Actionscript 3: Reading an RSS feed that requires authentication

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... />

Viewing all articles
Browse latest Browse all 2

Trending Articles