APIs and Code Snippets
Since many great websites have helped us learn and expedite our development by sharing their code we thought it would only be fair to do the same. As we come up with code modules or snippets that we think would be useful we will post them here.
Be sure to check back often to see if we post anything new.
Code Libraries/Modules/Snippets
- APTags - We’ve just release an Alpha version of our APTags Java Tagging API. It makes creating, updating and querying tags on items simple.
- JScrape - We’ve just release an Alpha version of our Java based HTML Scraping API, JScrape. It makes writing code that needs to extract data from web pages much simpler.
- JSP/Java based Spell Checker (using AJAX) - Check out our JSP Spell Checker which allows you to embed a spell checker into your JSP/Servlet based website with just a few easy steps. Contolled by AJAX the spell checker is easy to use and flexible.
- Yahoo GEOCode XML Bean The Yahoo GEOCode API (learn more here) can be easily used using this XML Bean. By using this been you can easily utilize the Yahoo GEOCode API from a Java program without having to work directly with the XML schema defined by the API.
Download Yahoo GEO Bean - Yahoo Local XML Bean The Yahoo Local API (learn more here) can be easily used using this XML Bean. By using this been you can easily utilize the Yahoo Local API from a Java program without having to work directly with the XML schema defined by the API.
Download Yahoo Local BeanThe XML Bean and sample code available below should explain how to get started. All you need to do is add the two jar files to your class path and then you can compile and run.import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import yahooMaps.*; import yahooMaps.ResultSetDocument.ResultSet; public class YahooGEOTest { public static String YAHOOURL = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=YahooDemo&location="; public static ResultType[] performGeocode(String location) { try { location = location.replaceAll(" ","+"); URL url = new URL(YAHOOURL+location); URLConnection uc = url.openConnection(); uc.setDefaultUseCaches(false); uc.setUseCaches(false); uc.setRequestProperty("Cache-Control","max-age=0,no-cache"); uc.setRequestProperty("Pragma","no-cache"); BufferedReader urlIn = new BufferedReader(new InputStreamReader(uc.getInputStream())); ResultSetDocument rsd = ResultSetDocument.Factory.parse(urlIn); ResultSet rs = rsd.getResultSet(); ResultType[] results = rs.getResultArray(); return results; } catch (Exception e) { System.out.println("Error: "+e.toString()); return null; } } public static void main (String[] args) { ResultType[] results = performGeocode(args[0]); if (results.length > 0) { //Sample API functions that are valid //get and set methods are created for all elements of the yahoo result. //String zip = results[0].getZip().substring(0,5); //String gLong = results[0].getLongitude().toString(); //String gLat = results[0].getLatitude().toString(); System.out.println(results[0].toString()); } } }

