Tuesday, August 18, 2009 at 7:52 PM.

godsTweetSuite.getListFromTwitterCounter

on getListFromTwitterCounter () {
	<<Changes
		<<5/9/09; 9:09:46 AM by DW
			<<Switched from TwitterHolic to TwitterCounter.
		<<5/4/09; 11:27:52 AM by DW
			<<Created. 
	local (adrdata = godsTweetSuite.init ());
	adrdata^.stats.ctListUpdates++;
	adrdata^.stats.whenLastListUpdate = clock.now ();
	
	local (feedurl = "http://twittercounter.com/rss/");
	local (xmltext = tcp.httpReadUrl (feedurl), xstruct);
	xml.compile (xmltext, @xstruct);
	local (adrrss = xml.getaddress (@xstruct, "rss"));
	local (adrchannel = xml.getaddress (adrrss, "channel"));
	<<scratchpad.xstruct = xstruct
	
	local (adritem);
	new (outlinetype, @scratchpad.rankoutline); edit (@scratchpad.rankoutline);
	for adritem in adrchannel {
		if nameof (adritem^) endswith "item" {
			local (rank = xml.getvalue (adritem, "rank"));
			local (screenname = xml.getvalue (adritem, "username"));
			op.insert (screenname + " is #" + rank, down)}};
	return;
	
	bundle { //get description
		local (url = "http://twitterholic.com/rss.xml", xstruct);
		xml.compile (tcp.httpreadurl (url), @xstruct);
		<<scratchpad.xstruct = xstruct
		local (adrrss = xml.getaddress (@xstruct, "rss"));
		local (adrchannel = xml.getaddress (adrrss, "channel"));
		local (adritem = xml.getaddress (adrchannel, "item"));
		description = xml.getvalue (adritem, "description")};
		<<scratchpad.description = description
	local (s = description);
	local (adrtable = @adrdata^.userProfiles, rank = 1);
	<<new (tabletype, adrtable)
	bundle { //set all the ranks to 0
		local (adr);
		for adr in adrtable {
			adr^.rank = 0}};
	loop {
		local (searchfor = "http://twitterholic.com/");
		local (ix = string.patternmatch (searchfor, s));
		if ix == 0 {
			break};
		s = string.delete (s, 1, ix + sizeof (searchfor) - 1);
		name = string.nthfield (s, '"', 1);
		local (adrprofile = godsTweetSuite.initProfile (name));
		adrprofile^.rank = rank++};
		<<adrtable^.[name] = rank++
	bundle { //delete all the profiles whose rank is 0
		local (i, adr);
		for i = sizeof (adrtable^) downto 1 {
			adr = @adrtable^ [i];
			if adr^.rank == 0 {
				delete (adr)}}}};
bundle { //readFeed
	getListFromTwitterCounter ()}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.