ActionScript 3 获取Twitter ATOM搜索Feed

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 获取Twitter ATOM搜索Feed相关的知识,希望对你有一定的参考价值。

var query:String = "greenwich";
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("http://search.twitter.com/search.atom?lang=en&q="+query));
myLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event) {
	myXML = new XML(e.target.data);
	myXML = removeNS(myXML);
        // then use myXML object as normal to access various parts of the feed
	for (var i:int = 0; i < myXML.entry.length(); i++){
		trace(myXML.entry.title[i]);
	}
}


function removeNS(anXML:XML){
	var xmlString = anXML.toXMLString();
	var xmlnsPattern = new RegExp("xmlns[^\"]*\"[^\"]*\"", "gi");
	var namespaceRemovedXML = xmlString.replace(xmlnsPattern, "");

	var aaaPattern = new RegExp("aaa:lang[^\"]*\"[^\"]*\"", "gi");
	var aaaRemovedXML = namespaceRemovedXML.replace(aaaPattern, "");
	
	var twitterPattern = new RegExp("twitter:", "gi");
	var twitterRemovedXML = aaaRemovedXML.replace(twitterPattern,"");
	
	var openSearchPattern = new RegExp("openSearch:", "gi");
	var openSearchRemovedXML = twitterRemovedXML.replace(openSearchPattern,"");

	var responseXML = new XML(openSearchRemovedXML);
	return responseXML;	
}

以上是关于ActionScript 3 获取Twitter ATOM搜索Feed的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 Twitter推文字符串编码实体实用程序

ActionScript 3 使用Twitter API的PlayBook OAuth示例

ActionScript 3 在Twitter上分享(Bit.ly缩短链接)[FLEX]

ActionScript 3 AS3:使用SWX访问Twitter用户的公共时间线

ActionScript 3 使用Actionscript获取谷歌网页排名

ActionScript 3 通过ActionScript 3(和as3corelib)获取美味的JSON提要