Subversion Repositories SmartDukaan

Rev

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

Rev 10162 Rev 10163
Line 18... Line 18...
18
 
18
 
19
public class UpdateSDIUsingPanel {
19
public class UpdateSDIUsingPanel {
20
	private static DefaultHttpClient client = new DefaultHttpClient();
20
	private static DefaultHttpClient client = new DefaultHttpClient();
21
	public static void main(String... args) throws ClientProtocolException, IOException{
21
	public static void main(String... args) throws ClientProtocolException, IOException{
22
		UpdateSDIUsingPanel UDSI = new UpdateSDIUsingPanel();
22
		UpdateSDIUsingPanel UDSI = new UpdateSDIUsingPanel();
23
		UDSI.handleLogin();
-
 
24
		UDSI.updateInventory(308L,"SDL061548809");
23
		UDSI.updateInventory(308L,"SDL061548809");
25
 
24
 
26
	}
25
	}
27
	int updateInventory(long stock,String supc) throws ClientProtocolException, IOException{
26
	int updateInventory(long stock,String supc) throws ClientProtocolException, IOException{
28
		HttpPost post = new HttpPost("http://seller.snapdeal.com/inventory/update");
27
		HttpPost post = new HttpPost("http://seller.snapdeal.com/inventory/update");
Line 40... Line 39...
40
			System.out.println(line);
39
			System.out.println(line);
41
		}
40
		}
42
		return 1;
41
		return 1;
43
	}
42
	}
44
 
43
 
45
	public void handleLogin() throws ClientProtocolException, IOException{
44
	public static void handleLogin() throws ClientProtocolException, IOException{
46
		HttpGet get = new HttpGet("http://selleraccounts.snapdeal.com/keymaker/login");
45
		HttpGet get = new HttpGet("http://selleraccounts.snapdeal.com/keymaker/login");
47
		HttpResponse response = null;
46
		HttpResponse response = null;
48
		try {
47
		try {
49
			response = client.execute(get);
48
			response = client.execute(get);
50
		} catch (ClientProtocolException e) {
49
		} catch (ClientProtocolException e) {
51
			// TODO Auto-generated catch block
-
 
52
			e.printStackTrace();
50
			e.printStackTrace();
53
		} catch (IOException e) {
51
		} catch (IOException e) {
54
			// TODO Auto-generated catch block
-
 
55
			e.printStackTrace();
52
			e.printStackTrace();
56
		}
53
		}
57
		BufferedReader rd = null;
54
		BufferedReader rd = null;
58
		try {
55
		try {
59
			rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
56
			rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
60
		} catch (IllegalStateException e1) {
57
		} catch (IllegalStateException e1) {
61
			// TODO Auto-generated catch block
-
 
62
			e1.printStackTrace();
58
			e1.printStackTrace();
63
		} catch (IOException e1) {
59
		} catch (IOException e1) {
64
			// TODO Auto-generated catch block
-
 
65
			e1.printStackTrace();
60
			e1.printStackTrace();
66
		}
61
		}
67
		String line = "";
62
		String line = "";
68
		StringBuffer sb = new StringBuffer();
63
		StringBuffer sb = new StringBuffer();
69
		try {
64
		try {
70
			while ((line = rd.readLine()) != null) {
65
			while ((line = rd.readLine()) != null) {
71
				sb.append(line);
66
				sb.append(line);
72
				//System.out.println(line);
-
 
73
			}
67
			}
74
		} catch (IOException e) {
68
		} catch (IOException e) {
75
			// TODO Auto-generated catch block
-
 
76
			e.printStackTrace();
69
			e.printStackTrace();
77
		}
70
		}
78
		int i= sb.toString().indexOf("name=\"lt\" value=");
71
		int i= sb.toString().indexOf("name=\"lt\" value=");
79
		char[] charArray = sb.toString().toCharArray();
72
		char[] charArray = sb.toString().toCharArray();
80
		String lt = "";
73
		String lt = "";