| Line 36... |
Line 36... |
| 36 |
|
36 |
|
| 37 |
public static final String AUTH_NAME = "flipkart";
|
37 |
public static final String AUTH_NAME = "flipkart";
|
| 38 |
public static final String USER_NAME = "flipkart-support@saholic.com";
|
38 |
public static final String USER_NAME = "flipkart-support@saholic.com";
|
| 39 |
public static final String PASSWORD = "bestmobiledeals2010";
|
39 |
public static final String PASSWORD = "bestmobiledeals2010";
|
| 40 |
public static final String SELLER_ID = "m2z93iskuj81qiid";
|
40 |
public static final String SELLER_ID = "m2z93iskuj81qiid";
|
| 41 |
public static final String CSRF = "wuru84MMNRMhRCWtlhydVdN9";
|
- |
|
| 42 |
public static String COOKIE ;
|
41 |
public static String COOKIE ;
|
| 43 |
|
42 |
|
| 44 |
static String emailFromAddress;
|
43 |
static String emailFromAddress;
|
| 45 |
static String password;
|
44 |
static String password;
|
| 46 |
static GmailUtils mailer;
|
45 |
static GmailUtils mailer;
|
| Line 69... |
Line 68... |
| 69 |
//sendTo = new String[]{"manish.sharma@shop2020.in"};
|
68 |
//sendTo = new String[]{"manish.sharma@shop2020.in"};
|
| 70 |
sendTo = new String[]{ "sandeep.sachdeva@shop2020.in", "manish.sharma@shop2020.in", "rajneesh.arora@shop2020.in",
|
69 |
sendTo = new String[]{ "sandeep.sachdeva@shop2020.in", "manish.sharma@shop2020.in", "rajneesh.arora@shop2020.in",
|
| 71 |
"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
|
70 |
"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
|
| 72 |
"yukti.jain@shop2020.in","yatin.singh@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","anikendra.das@shop2020.in"};
|
71 |
"yukti.jain@shop2020.in","yatin.singh@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","anikendra.das@shop2020.in"};
|
| 73 |
}
|
72 |
}
|
| - |
|
73 |
|
| - |
|
74 |
public static String getCsrfValue() throws ClientProtocolException, IOException, JSONException{
|
| - |
|
75 |
HttpResponse response;
|
| - |
|
76 |
|
| - |
|
77 |
BufferedReader rd= null;
|
| - |
|
78 |
HttpGet get_new;
|
| - |
|
79 |
|
| - |
|
80 |
String line = "";
|
| - |
|
81 |
|
| - |
|
82 |
get_new = new HttpGet("https://seller.flipkart.com/sfx");
|
| - |
|
83 |
get_new.addHeader("Cookie",COOKIE+"; __utmt=1; __utma=143439159.1675929865.1422546011.1422546011.1422546011.1; __utmb=143439159.1.10.1422546011; __utmc=143439159; __utmz=143439159.1422546011.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); is_login=true; sellerId=m2z93iskuj81qiid");
|
| - |
|
84 |
get_new.addHeader("Host","seller.flipkart.com");
|
| - |
|
85 |
get_new.addHeader("User-agent", "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31");
|
| - |
|
86 |
get_new.addHeader("Connection","keep-alive");
|
| - |
|
87 |
|
| - |
|
88 |
response = client.execute(get_new);
|
| - |
|
89 |
|
| - |
|
90 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| - |
|
91 |
|
| - |
|
92 |
String csrfVal = "";
|
| - |
|
93 |
while ((line = rd.readLine()) != null) {
|
| - |
|
94 |
if(line.contains("var seller = ")){
|
| - |
|
95 |
String desiredLine = line;
|
| - |
|
96 |
desiredLine = desiredLine.split("var seller = ")[1].trim();
|
| - |
|
97 |
desiredLine = desiredLine.substring(0, desiredLine.length()-1);
|
| - |
|
98 |
System.out.println("desiredLine... "+desiredLine);
|
| - |
|
99 |
JSONObject jsonObj = new JSONObject(desiredLine);
|
| - |
|
100 |
|
| - |
|
101 |
csrfVal=(String)jsonObj.get("csrf");
|
| - |
|
102 |
System.out.println(csrfVal);
|
| - |
|
103 |
}
|
| - |
|
104 |
}
|
| - |
|
105 |
return csrfVal;
|
| - |
|
106 |
}
|
| 74 |
|
107 |
|
| 75 |
|
108 |
|
| 76 |
public boolean updatePrice(String skuAtFlipkart, String sellingPrice) throws ClientProtocolException, IOException, JSONException{
|
109 |
public boolean updatePrice(String skuAtFlipkart, String sellingPrice) throws ClientProtocolException, IOException, JSONException{
|
| 77 |
|
110 |
|
| 78 |
if (!Boolean.valueOf(UPDATE_PRICE_ON_FK)){
|
111 |
if (!Boolean.valueOf(UPDATE_PRICE_ON_FK)){
|
| Line 117... |
Line 150... |
| 117 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
150 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 118 |
line="";
|
151 |
line="";
|
| 119 |
while ((line = rd.readLine()) != null) {
|
152 |
while ((line = rd.readLine()) != null) {
|
| 120 |
System.out.println(line);
|
153 |
System.out.println(line);
|
| 121 |
}
|
154 |
}
|
| - |
|
155 |
|
| - |
|
156 |
String csrfVal= getCsrfValue();
|
| - |
|
157 |
|
| 122 |
String data = "{\"refiners\":{\"sku_id\":[\""+skuAtFlipkart+"\"]},\"verticalGroup\":{},\"sellerId\":\""+SELLER_ID+"\",\"pageSize\":10,\"pageNumber\":1,\"state\":\"LIVE\"}";
|
158 |
String data = "{\"refiners\":{\"sku_id\":[\""+skuAtFlipkart+"\"]},\"verticalGroup\":{},\"sellerId\":\""+SELLER_ID+"\",\"pageSize\":10,\"pageNumber\":1,\"state\":\"LIVE\",\"_csrf\":\""+csrfVal+"\"}";
|
| 123 |
//String data = "{\"refiners\":{\"sku_id\":[\"12442\"]},\"verticalGroup\":{},\"sellerId\":\"m2z93iskuj81qiid\",\"pageSize\":10,\"pageNumb
|
159 |
//String data = "{\"refiners\":{\"sku_id\":[\"12442\"]},\"verticalGroup\":{},\"sellerId\":\"m2z93iskuj81qiid\",\"pageSize\":10,\"pageNumb
|
| 124 |
logger.info(data);
|
160 |
logger.info(data);
|
| 125 |
//HttpGet get_new = new HttpGet("https://seller.flipkart.com/dashboard/som/new_order_items?status=on_hold%2Capproved.payment_approved&sort=confirm_by_date&page="+i+"&page_size=100&_="+time);
|
161 |
//HttpGet get_new = new HttpGet("https://seller.flipkart.com/dashboard/som/new_order_items?status=on_hold%2Capproved.payment_approved&sort=confirm_by_date&page="+i+"&page_size=100&_="+time);
|
| 126 |
HttpPost httppost = new HttpPost("https://seller.flipkart.com/createproduct/getproductrowsforstate?sellerId=m2z93iskuj81qiid");
|
162 |
HttpPost httppost = new HttpPost("https://seller.flipkart.com/createproduct/getproductrowsforstate?sellerId=m2z93iskuj81qiid");
|
| 127 |
httppost.addHeader("Cookie",COOKIE+"; __utmt=1; __utma=143439159.1675929865.1422546011.1422546011.1422546011.1; __utmb=143439159.1.10.1422546011; __utmc=143439159; __utmz=143439159.1422546011.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); is_login=true; sellerId=m2z93iskuj81qiid");
|
163 |
httppost.addHeader("Cookie",COOKIE+"; __utmt=1; __utma=143439159.1675929865.1422546011.1422546011.1422546011.1; __utmb=143439159.1.10.1422546011; __utmc=143439159; __utmz=143439159.1422546011.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); is_login=true; sellerId=m2z93iskuj81qiid");
|
| Line 140... |
Line 176... |
| 140 |
StringBuilder sb = new StringBuilder();
|
176 |
StringBuilder sb = new StringBuilder();
|
| 141 |
while ((line = rd1.readLine()) != null) {
|
177 |
while ((line = rd1.readLine()) != null) {
|
| 142 |
sb.append(line);
|
178 |
sb.append(line);
|
| 143 |
}
|
179 |
}
|
| 144 |
response1.getEntity().consumeContent();
|
180 |
response1.getEntity().consumeContent();
|
| 145 |
JSONArray jsonArray = new JSONArray(sb.toString());
|
181 |
System.out.println(sb.toString());
|
| 146 |
String listingId = "";
|
- |
|
| 147 |
for (int i = 0, size = jsonArray.length(); i < size; i++){
|
182 |
JSONObject jsonResult = new JSONObject(sb.toString());
|
| 148 |
JSONObject x = jsonArray.getJSONObject(i);
|
183 |
JSONArray jsonResultArr = (JSONArray)(JSONArray)jsonResult.get("data");
|
| 149 |
listingId = x.get("listing").toString();
|
184 |
String listingId = ((JSONObject)jsonResultArr.get(0)).get("listing").toString();
|
| 150 |
}
|
- |
|
| 151 |
|
185 |
|
| 152 |
data = getPostForSku(skuAtFlipkart, sellingPrice, listingId);
|
186 |
data = getPostForSku(skuAtFlipkart, sellingPrice, listingId, csrfVal);
|
| 153 |
logger.info(listingId);
|
187 |
logger.info(listingId);
|
| 154 |
httppost = new HttpPost("https://seller.flipkart.com/sellerListing/listing/updateListings?sellerId=m2z93iskuj81qiid");
|
188 |
httppost = new HttpPost("https://seller.flipkart.com/sellerListing/listing/updateListings?sellerId=m2z93iskuj81qiid");
|
| 155 |
httppost.addHeader("Cookie",COOKIE+"; __utmt=1; __utma=143439159.1675929865.1422546011.1422546011.1422546011.1; __utmb=143439159.1.10.1422546011; __utmc=143439159; __utmz=143439159.1422546011.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); is_login=true; sellerId=m2z93iskuj81qiid");
|
189 |
httppost.addHeader("Cookie",COOKIE+"; __utmt=1; __utma=143439159.1675929865.1422546011.1422546011.1422546011.1; __utmb=143439159.1.10.1422546011; __utmc=143439159; __utmz=143439159.1422546011.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); is_login=true; sellerId=m2z93iskuj81qiid");
|
| 156 |
httppost.addHeader("User-agent", USER_AGENT);
|
190 |
httppost.addHeader("User-agent", USER_AGENT);
|
| 157 |
httppost.addHeader("Referer", "https://seller.flipkart.com/appV2");
|
191 |
httppost.addHeader("Referer", "https://seller.flipkart.com/appV2");
|
| - |
|
192 |
httppost.addHeader("fk-csrf-token",csrfVal);
|
| 158 |
|
193 |
|
| 159 |
input = null;
|
194 |
input = null;
|
| 160 |
input = new StringEntity(data);
|
195 |
input = new StringEntity(data);
|
| 161 |
input.setContentType("application/json");
|
196 |
input.setContentType("application/json");
|
| 162 |
httppost.setEntity(input);
|
197 |
httppost.setEntity(input);
|
| Line 175... |
Line 210... |
| 175 |
mailer.sendSSLMessage(sendTo, "Flipkart Pricing Sent Response ", sb.toString(), emailFromAddress, password,new ArrayList<File>());
|
210 |
mailer.sendSSLMessage(sendTo, "Flipkart Pricing Sent Response ", sb.toString(), emailFromAddress, password,new ArrayList<File>());
|
| 176 |
} catch (MessagingException e) {
|
211 |
} catch (MessagingException e) {
|
| 177 |
e.printStackTrace();
|
212 |
e.printStackTrace();
|
| 178 |
}
|
213 |
}
|
| 179 |
response1.getEntity().consumeContent();
|
214 |
response1.getEntity().consumeContent();
|
| 180 |
jsonArray = new JSONArray(sb.toString());
|
215 |
JSONArray jsonArray = new JSONArray(sb.toString());
|
| 181 |
String listingPrice = "";
|
216 |
String listingPrice = "";
|
| 182 |
for (int i = 0, size = jsonArray.length(); i < size; i++){
|
217 |
for (int i = 0, size = jsonArray.length(); i < size; i++){
|
| 183 |
JSONObject x = jsonArray.getJSONObject(i);
|
218 |
JSONObject x = jsonArray.getJSONObject(i);
|
| 184 |
listingPrice = x.get("listingPrice").toString();
|
219 |
listingPrice = x.get("listingPrice").toString();
|
| 185 |
}
|
220 |
}
|
| Line 189... |
Line 224... |
| 189 |
}
|
224 |
}
|
| 190 |
return false;
|
225 |
return false;
|
| 191 |
}
|
226 |
}
|
| 192 |
|
227 |
|
| 193 |
|
228 |
|
| 194 |
public static String getPostForSku(String sku, String sellingPrice, String listingId){
|
229 |
public static String getPostForSku(String sku, String sellingPrice, String listingId, String csrf){
|
| 195 |
return "{\"sellerId\":\""+SELLER_ID+"\"" +
|
230 |
return "{\"sellerId\":\""+SELLER_ID+"\"" +
|
| 196 |
",\"bulkListingRequest\":{\"listings\":" +
|
231 |
",\"bulkListingRequest\":{\"listings\":" +
|
| 197 |
"[{\"listingId\":\""+listingId+"\",\"attributeValues\":" +
|
232 |
"[{\"listingId\":\""+listingId+"\",\"attributeValues\":" +
|
| 198 |
"{\"selling_price\":\""+sellingPrice+"\"},\"" +
|
233 |
"{\"selling_price\":\""+sellingPrice+"\"},\"" +
|
| 199 |
"listingValidations\":" +
|
234 |
"listingValidations\":" +
|
| 200 |
"{\"PRICE_ERROR_CHECK\":" +
|
235 |
"{\"PRICE_ERROR_CHECK\":" +
|
| 201 |
"\"disable\"}}]}," +
|
236 |
"\"disable\"}}]}," +
|
| 202 |
"\"_csrf\":\""+CSRF+"\"}";
|
237 |
"\"_csrf\":\""+csrf+"\"}";
|
| 203 |
//return "{\"sellerId\":\"m2z93iskuj81qiid\",\"bulkListingRequest\":{\"listings\":[{\"listingId\":\"LSTACCDSN8FSJTTYPCQZWWGJL\",\"attributeValues\":{\"selling_price\":\"4901\"},\"listingValidations\":{\"PRICE_ERROR_CHECK\":\"enable\"}}]},\"_csrf\":\"wuru84MMNRMhRCWtlhydVdN9\"}";
|
238 |
//return "{\"sellerId\":\"m2z93iskuj81qiid\",\"bulkListingRequest\":{\"listings\":[{\"listingId\":\"LSTACCDSN8FSJTTYPCQZWWGJL\",\"attributeValues\":{\"selling_price\":\"4901\"},\"listingValidations\":{\"PRICE_ERROR_CHECK\":\"enable\"}}]},\"_csrf\":\"wuru84MMNRMhRCWtlhydVdN9\"}";
|
| 204 |
}
|
239 |
}
|
| 205 |
|
240 |
|
| 206 |
public static void main(String[] args) throws ClientProtocolException, IOException, JSONException{
|
241 |
public static void main(String[] args) throws ClientProtocolException, IOException, JSONException{
|
| 207 |
FlipkartPricingPannel fkPricing = new FlipkartPricingPannel();
|
242 |
FlipkartPricingPannel fkPricing = new FlipkartPricingPannel();
|