new Thread() { @Override public void run() { String RESOURCE_URL = "http://www.woocommerce.com/wp-json/wc/v1/api/"; String SCOPE = "*"; //all permissions Response response; OAuthRequest request; String responsebody = ""; OAuthService service = new ServiceBuilder().provider(OneLeggedApi10.class) .apiKey("yourConsumerKey") .apiSecret("yourConsumerSecret") .signatureType(SignatureType.QueryString) .debug() /*.scope(SCOPE).*/ .build(); request = new OAuthRequest(Verb.GET, RESOURCE_URL); service.signRequest(new Token("", ""), request); // Now let go and ask for a protected resource! Log.d("scribe","Now we're going to access a protected resource..."); try { response = request.send(); if (response.isSuccessful()) { responsebody = response.getBody(); Log.v("response", responsebody); } } catch (Exception e) { e.printStackTrace(); } } }.start();
This code is updated from above, the above code works by getting JSON from the Wordpress Woocommerce API. But if you are interested in how to use Thread, this is the answer. And I add Log.v to get json response.
source share