Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. private static void sendGet(String token) throws Exception {
  2.         String sn = shopname;
  3.         int shoplen = sn.length()-14;
  4.         String shop = sn.substring(0, shoplen);
  5.         String url = "https://"+shop+".myshopify.com/admin/themes.json?fields=id,role";
  6.         URL obj = new URL(url);
  7.         HttpURLConnection con = (HttpURLConnection) obj.openConnection();
  8.         con.setRequestMethod("GET");
  9.         con.setRequestProperty("X-Shopify-Access-Token", token);
  10.         con.setRequestProperty("User-Agent", USER_AGENT);
  11.         con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
  12.         con.setRequestProperty("Content-Type", "application/json");
  13.         int responseCode = con.getResponseCode();
  14.         System.out.println("\nSending 'GET' request to URL : " + url);
  15.         System.out.println("Response Code : " + responseCode);
  16.         BufferedReader in = new BufferedReader(
  17.         new InputStreamReader(con.getInputStream()));
  18.         String inputLine;
  19.         StringBuffer response = new StringBuffer();
  20.         while ((inputLine = in.readLine()) != null) {
  21.             response.append(inputLine);
  22.         }
  23.         in.close();
  24.         System.out.println(response.toString());
  25.         String substr = "main";
  26.         int index= response.toString().indexOf(substr);
  27.         System.out.println(index);
  28.         final String themeid = response.toString().substring(index-17, index-9);
  29.         System.out.println(themeid);
  30.         sendPostscripttag(token);
  31.         sendPutcopytheme(token,themeid);
  32.         sendPutcreatesnippet(token,themeid);
  33.         sendPutchangetheme(token,themeid);
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement