/* * Copyright 2008-2011 Wyld Collective / Obx Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * FeedPull * * This example shows how to get data from a syndicated * feed (RSS or ATOM) from a URL. The sketch fetches information * from a feed, prints out its entries to the console, and continues * pulling entries from the feed at interval if any are available. */ //romefeeder import com.wyldco.romefeeder.*; import com.sun.syndication.feed.synd.*; Feeder feeder; // the feeder SyndEntry entry; // a feed entry void setup() { //create the feeder feeder = new Feeder(this); //turn on output to the console (useful for debugging) feeder.verbose = true; //set sort by published date //default is unsorted (i.e. as ordered in the feed) feeder.sortByPublishedDate(); //if you are exporting your sketch to an applet //set the proxy to bypass applet domain limitations //make sure you copy the proxy.php provided in the //data folder of example SimpleUrlFeed to your applet directory //feeder.setProxy("http://[urlToApplet]/FeedPull/applet/proxy.php"); //set the update interval to check for new posts in the loaded feed(s) feeder.setUpdateInterval(5*60*1000); // milliseconds //start updating feeder.startUpdate(); //load the feed feeder.load("http://www.thestranger.com/seattle/Rss.xml?category=258"); } void draw() { //display the next entries while (feeder.hasNext()) { //get the next entry entry = feeder.next(); println("\n" + entry.getTitle()); println(" + " + entry.getPublishedDate()); println(" + " + entry.getLink()); } }