/* * 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. * */ /** * TwitterFeed * * This example shows how to get entries from a simple Twitter search, * which is returned as a syndicated feed. The sketch sends a search * query to Twitter, prints out its entries to the console, and continues * pulling entries at interval if any are available. */ //romefeeder import com.wyldco.romefeeder.*; import com.sun.syndication.feed.synd.*; TwitterFeeder feeder; // the feeder SyndEntry entry; // a feed entry void setup() { //create the feeder feeder = new TwitterFeeder(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]/TwitterFeed/applet/proxy.php"); //set the update interval to check for new posts in the loaded feed(s) feeder.setUpdateInterval(30*1000); // milliseconds //start updating feeder.startUpdate(); //search twitter, in this case for tweets containing 'self' feeder.search("self"); } 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()); } }