Subversion Repositories SmartDukaan

Rev

Rev 12835 | Rev 13765 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12835 Rev 13668
Line 33... Line 33...
33
    public static final String AUTH_NAME = "flipkart";
33
    public static final String AUTH_NAME = "flipkart";
34
    public static final String USER_NAME = "flipkart-support@saholic.com";
34
    public static final String USER_NAME = "flipkart-support@saholic.com";
35
    public static final String PASSWORD = "076c27ee24d7596b06608a8ed2559f87";
35
    public static final String PASSWORD = "076c27ee24d7596b06608a8ed2559f87";
36
    public static final String SELLER_ID = "m2z93iskuj81qiid";
36
    public static final String SELLER_ID = "m2z93iskuj81qiid";
37
    public static final String CSRF = "wuru84MMNRMhRCWtlhydVdN9";
37
    public static final String CSRF = "wuru84MMNRMhRCWtlhydVdN9";
38
    public static final String COOKIE = "T=TI141147280750274359991498309202525657388536723248248488328249492067; " +
-
 
39
    "__sonar=16983180403917152637; __gads=ID=c15eba68f7f44861:T=1411472817:S=ALNI_MYyU0QfJ923BqkcDhqFlRpZxMcA8w; " +
-
 
40
    "cmp_id=hp_dotd_4_DOTDOnBajajMixerGrinder_Sep23.|1414064820638; S=d1t16GpsIdt0JTsYuFF%2FMaE7jTGYozxMXM5a3ktJD24TBohceobkUv8l4GDr4KNLkLs5BOgnhsqkZNQRh2Lzrx%2B77zQ%3D%3D; " +
-
 
41
    "km_lv=x; __utma=19769839.1065606807.1411472808.1411472808.1411624009.2; __utmc=19769839; __utmz=19769839.1411472808.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);" +
-
 
42
    " s_cc=true; s_sq=%5B%5BB%5D%5D; prd_day=2|1411645620637; s_ppv=21; SN=2.VI89D3B4F7B5534B3C9EADE3BBD925875A.SI05ED43E07EAF40E9B4F265F5F2B1074D.VS141162400679268773093.1411624676;" +
-
 
43
    "VID=2.VI89D3B4F7B5534B3C9EADE3BBD925875A.1411624676.VS141162400679268773093; NSID=2.SI05ED43E07EAF40E9B4F265F5F2B1074D.1411624676.VI89D3B4F7B5534B3C9EADE3BBD925875A; " +
-
 
44
    "connect.sid=s%3AaUlfUN00goYPkqRHXtAbM6Nh.EBDDk9%2F0rQDXGb%2B23IEJ4QgrAgKFpXU%2FLOjuQyxJo44; is_login=true; sellerId=m2z93iskuj81qiid; __utma=143439159.1617147053.1411568832.1411568832.1411624688.2; " +
-
 
45
    "__utmb=143439159.17.10.1411624688; __utmc=143439159; __utmz=143439159.1411568832.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ga=GA1.2.1617147053.1411568832; _gat=1; kvcd=1411627978463; km_ai=m2z93iskuj81qiid; " +
-
 
46
    "km_ni=m2z93iskuj81qiid; km_vs=1; km_uq=";
38
    public static String COOKIE ;
47
 
39
 
48
    public static final String SELLER_HOME = "seller.flipkart.com";
40
    public static final String SELLER_HOME = "seller.flipkart.com";
49
    public static final String USER_AGENT = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63";
41
    public static final String USER_AGENT = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63";
50
    public static final HttpClient client = new DefaultHttpClient();
42
    public static final HttpClient client = new DefaultHttpClient();
51
    
43
    
Line 66... Line 58...
66
        
58
        
67
        if (!Boolean.valueOf(UPDATE_PRICE_ON_FK)){
59
        if (!Boolean.valueOf(UPDATE_PRICE_ON_FK)){
68
            return true;
60
            return true;
69
        }
61
        }
70
 
62
 
71
        HttpPost post = new HttpPost("https://seller.flipkart.com/login");
63
        HttpGet get_new;
72
        BufferedReader rd= null;
64
        BufferedReader rd= null;
-
 
65
		get_new = new HttpGet("https://seller.flipkart.com/");
-
 
66
		get_new.addHeader("Host","seller.flipkart.com");
-
 
67
        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");
-
 
68
        get_new.addHeader("Connection","keep-alive");
-
 
69
        
-
 
70
        HttpResponse response = client.execute(get_new);
-
 
71
        rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-
 
72
        String line = "";
-
 
73
        while ((line = rd.readLine()) != null) {
-
 
74
            System.out.println(line);
-
 
75
        }
-
 
76
        COOKIE = response.getFirstHeader("Set-Cookie") == null ? "" : 
-
 
77
            response.getFirstHeader("Set-Cookie").getValue();
-
 
78
        
-
 
79
        System.out.println("Cookies Before Login "+ COOKIE);
-
 
80
        
-
 
81
        HttpPost post = new HttpPost("https://seller.flipkart.com/login");
-
 
82
        
73
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
83
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
74
        nameValuePairs.add(new BasicNameValuePair("authName",
84
        nameValuePairs.add(new BasicNameValuePair("authName",
75
                AUTH_NAME));
85
                AUTH_NAME));
76
        nameValuePairs.add(new BasicNameValuePair("username",
86
        nameValuePairs.add(new BasicNameValuePair("username",
77
                USER_NAME));
87
                USER_NAME));
Line 79... Line 89...
79
                PASSWORD));
89
                PASSWORD));
80
        post.addHeader("Cookie",COOKIE);
90
        post.addHeader("Cookie",COOKIE);
81
        post.addHeader("User-agent", USER_AGENT);
91
        post.addHeader("User-agent", USER_AGENT);
82
        post.addHeader("Referer", SELLER_HOME);
92
        post.addHeader("Referer", SELLER_HOME);
83
        post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
93
        post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
84
        HttpResponse response = client.execute(post);
94
        response = client.execute(post);
-
 
95
        COOKIE = response.getFirstHeader("Set-Cookie") == null ? "" : 
-
 
96
            response.getFirstHeader("Set-Cookie").getValue();
-
 
97
		System.out.println("cookies "+COOKIE);
85
        rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
98
        rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
86
        String line="";
99
        line="";
87
        while ((line = rd.readLine()) != null) {
100
        while ((line = rd.readLine()) != null) {
88
            System.out.println(line);
101
            System.out.println(line);
89
        }
102
        }
90
        String data = "{\"refiners\":{\"sku_id\":[\""+skuAtFlipkart+"\"]},\"verticalGroup\":{},\"sellerId\":\""+SELLER_ID+"\",\"pageSize\":10,\"pageNumber\":1,\"state\":\"LIVE\"}";
103
        String data = "{\"refiners\":{\"sku_id\":[\""+skuAtFlipkart+"\"]},\"verticalGroup\":{},\"sellerId\":\""+SELLER_ID+"\",\"pageSize\":10,\"pageNumber\":1,\"state\":\"LIVE\"}";
91
        //String data = "{\"refiners\":{\"sku_id\":[\"12442\"]},\"verticalGroup\":{},\"sellerId\":\"m2z93iskuj81qiid\",\"pageSize\":10,\"pageNumb
104
        //String data = "{\"refiners\":{\"sku_id\":[\"12442\"]},\"verticalGroup\":{},\"sellerId\":\"m2z93iskuj81qiid\",\"pageSize\":10,\"pageNumb
92
        logger.info(data);
105
        logger.info(data);
93
        //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);
106
        //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);
94
        HttpPost httppost = new HttpPost("https://seller.flipkart.com/sellerListing/listing/listingsForContext?sellerId=m2z93iskuj81qiid");
107
        HttpPost httppost = new HttpPost("https://seller.flipkart.com/sellerListing/listing/listingsForContext?sellerId=m2z93iskuj81qiid");
95
        httppost.addHeader("Cookie",COOKIE);
108
        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");
96
        httppost.addHeader("User-agent", USER_AGENT);
109
        httppost.addHeader("User-agent", USER_AGENT);
97
        httppost.addHeader("Referer", "https://seller.flipkart.com/appV2");
110
        httppost.addHeader("Referer", "https://seller.flipkart.com/appV2");
98
 
111
 
99
        StringEntity input = null;
112
        StringEntity input = null;
100
        input = new StringEntity(data);
113
        input = new StringEntity(data);
Line 118... Line 131...
118
        }
131
        }
119
        
132
        
120
        data = getPostForSku(skuAtFlipkart, sellingPrice, listingId);
133
        data = getPostForSku(skuAtFlipkart, sellingPrice, listingId);
121
        logger.info(listingId);
134
        logger.info(listingId);
122
        httppost = new HttpPost("https://seller.flipkart.com/sellerListing/listing/updateListings?sellerId=m2z93iskuj81qiid");
135
        httppost = new HttpPost("https://seller.flipkart.com/sellerListing/listing/updateListings?sellerId=m2z93iskuj81qiid");
123
        httppost.addHeader("Cookie",COOKIE);
136
        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");
124
        httppost.addHeader("User-agent", USER_AGENT);
137
        httppost.addHeader("User-agent", USER_AGENT);
125
        httppost.addHeader("Referer", "https://seller.flipkart.com/appV2");
138
        httppost.addHeader("Referer", "https://seller.flipkart.com/appV2");
126
 
139
 
127
        input = null;
140
        input = null;
128
        input = new StringEntity(data);
141
        input = new StringEntity(data);