Monday, November 08, 2010 at 12:01 AM.

system.verbs.apps.Flickr.readFeed

on readFeed (url, adrflchanged=nil) {
	<<Changes
		<<9/30/07; 9:51:00 AM by DW
			<<Created. 
			<<We respect the Last-Modified header, keeping a cache of the feed text, to conserve bandwidth. If the caller wants to know if there was a change, pass in the address of a boolean in flchanged,
	local (urllist = string.urlsplit (url), startticks = clock.ticks ());
	Flickr.init (); //sets up system.temp.flickrglue
	local (adrcache = @system.temp.flickrglue.feedCache);
	if not defined (adrcache^) {
		new (tabletype, adrcache)};
	adrcache = @adrcache^.[url];
	if defined (adrcache^) {
		try {
			local (headers);
			local (s = string.httpResultSplit (tcp.httpClient ("HEAD", server:urllist [2], path:urllist [3], flMessages:false, ctFollowRedirects:3), @headers));
			<<scratchpad.headers = headers
			if date (headers.["Last-Modified"]) == adrcache^.lastModifiedHeader {
				adrcache^.ctRefs++;
				adrcache^.ctTicksLastRead = clock.ticks () - startticks;
				if adrflchanged != nil {
					adrflchanged^ = false};
				return (adrcache^.xmltext)}}};
	if not defined (adrcache^) {
		local (headers);
		new (tabletype, adrcache)};
	adrcache^.ctRefs = 0;
	adrcache^.xmltext = string.httpResultSplit (tcp.httpClient ("GET", server:urllist [2], path:urllist [3], flMessages:false, ctFollowRedirects:3), @headers);
	adrcache^.lastModifiedHeader = date (headers.["Last-Modified"]);
	adrcache^.ctTicksLastRead = clock.ticks () - startticks;
	if adrflchanged != nil {
		adrflchanged^ = true};
	return (adrcache^.xmltext)};
bundle { //test code
	local (adruser);
	for adruser in @twitterGramData.users {
		if defined (adruser^.flickrToTwitter.rssUrl) {
			msg (nameof (adruser^));
			readFeed (adruser^.flickrToTwitter.rssUrl)}};
	return;
	readFeed (twitterGramData.users.davewiner.flickrToTwitter.rssUrl)}



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.