Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void sendGet(String token) throws Exception {
- String sn = shopname;
- int shoplen = sn.length()-14;
- String shop = sn.substring(0, shoplen);
- String url = "https://"+shop+".myshopify.com/admin/themes.json?fields=id,role";
- URL obj = new URL(url);
- HttpURLConnection con = (HttpURLConnection) obj.openConnection();
- con.setRequestMethod("GET");
- con.setRequestProperty("X-Shopify-Access-Token", token);
- con.setRequestProperty("User-Agent", USER_AGENT);
- con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
- con.setRequestProperty("Content-Type", "application/json");
- int responseCode = con.getResponseCode();
- System.out.println("\nSending 'GET' request to URL : " + url);
- System.out.println("Response Code : " + responseCode);
- BufferedReader in = new BufferedReader(
- new InputStreamReader(con.getInputStream()));
- String inputLine;
- StringBuffer response = new StringBuffer();
- while ((inputLine = in.readLine()) != null) {
- response.append(inputLine);
- }
- in.close();
- System.out.println(response.toString());
- String substr = "main";
- int index= response.toString().indexOf(substr);
- System.out.println(index);
- final String themeid = response.toString().substring(index-17, index-9);
- System.out.println(themeid);
- sendPostscripttag(token);
- sendPutcopytheme(token,themeid);
- sendPutcreatesnippet(token,themeid);
- sendPutchangetheme(token,themeid);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement