Posted By

sukantahazra on 02/13/10


Tagged

snipplr api


Versions (?)

Using the snipplr API in java


 / Published in: Java
 

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package net.hazra.xmlrpctutorial;
  7.  
  8. import java.net.URL;
  9. import java.util.*;
  10. import java.util.Vector;
  11. import org.apache.xmlrpc.client.XmlRpcClient;
  12. import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
  13.  
  14.  
  15.  
  16.  
  17.  
  18. public class Main {
  19.  
  20. private static String keyId = "your key id";
  21.  
  22. public static void main( String args[] ) throws Exception {
  23.  
  24. XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
  25. config.setServerURL(new URL("http://snipplr.com/xml-rpc.php"));
  26.  
  27. XmlRpcClient client = new XmlRpcClient();
  28. client.setConfig(config);
  29.  
  30. Vector params = new Vector();
  31. params.addElement(keyId);
  32.  
  33.  
  34. Object[] results = (Object[]) client.execute( "snippet.list", params );
  35.  
  36. if ( results != null ) {
  37. HashMap r = (HashMap) results[0];
  38. Set keys = r.keySet();
  39. Collection values = r.values();
  40.  
  41. System.out.println(keys);
  42. System.out.println(values);
  43. }
  44.  
  45. }
  46. }

Report this snippet  

You need to login to post a comment.