Return to Snippet

Revision: 23801
at February 13, 2010 10:41 by sukantahazra


Initial Code
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.hazra.xmlrpctutorial;

import java.net.URL;
import java.util.*;
import java.util.Vector;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;





public class Main {

    private static String keyId = "your key id";

    public static void main( String args[] ) throws Exception {

        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
        config.setServerURL(new URL("http://snipplr.com/xml-rpc.php"));

        XmlRpcClient client = new XmlRpcClient();
        client.setConfig(config);

        Vector params = new Vector();
        params.addElement(keyId);
        

        Object[] results = (Object[]) client.execute( "snippet.list", params );

        if ( results != null ) {
            HashMap r = (HashMap) results[0];
            Set keys = r.keySet();
            Collection values = r.values();

            System.out.println(keys);
            System.out.println(values);
        }

    }
}

Initial URL


Initial Description


Initial Title
Using the snipplr API in java

Initial Tags
api

Initial Language
Java