Sample code for 30+ languages & platforms
Java

Magento Request with OAuth1.0a Authentication

See more Magento Examples

Demonstrates sending a Magento request with OAuth1.0a authentication. (Using the Magento 1.x REST API)

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.JsonObject;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example requires the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Http http = new Http();

        http.setOAuth1(true);
        http.setOAuthVerifier("");
        http.setOAuthConsumerKey("MAGENTO_CONSUMER_KEY");
        http.setOAuthConsumerSecret("MAGENTO_CONSUMER_SECRET");
        http.setOAuthToken("MAGENTO__TOKEN");
        http.setOAuthTokenSecret("MAGENTO_TOKEN_SECRET");

        http.setAccept("application/json");

        String url = "http://www.inart.com/api/rest/products/store/2?limit=20&page=1";

        String jsonStr;
        try {
            jsonStr = http.quickGetStr(url);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        System.out.println("Response status code = " + http.getLastStatus());

        JsonObject json = new JsonObject();
        json.load(jsonStr);
        json.setEmitCompact(false);

        System.out.println(json.emit());

        // Use this online tool to generate parsing code from sample JSON:
        // Generate Parsing Code from JSON
    }
}