| 21205 |
rajender |
1 |
package com.saholic.profittill.Services;
|
|
|
2 |
|
|
|
3 |
import android.util.Base64;
|
|
|
4 |
|
|
|
5 |
import org.apache.http.HttpResponse;
|
|
|
6 |
import org.apache.http.NameValuePair;
|
|
|
7 |
import org.apache.http.client.ClientProtocolException;
|
|
|
8 |
import org.apache.http.client.HttpClient;
|
|
|
9 |
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
10 |
import org.apache.http.client.methods.HttpPost;
|
|
|
11 |
import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
12 |
import org.apache.http.message.BasicNameValuePair;
|
|
|
13 |
import org.json.JSONObject;
|
|
|
14 |
|
|
|
15 |
import java.io.IOException;
|
|
|
16 |
import java.util.ArrayList;
|
|
|
17 |
|
|
|
18 |
public class PushDataRunnable implements Runnable {
|
|
|
19 |
String basicAuth = "Basic " + Base64.encodeToString("dtr:dtr18Feb2015".getBytes(), Base64.NO_WRAP);
|
|
|
20 |
String url;
|
|
|
21 |
private JSONObject obj;
|
|
|
22 |
public PushDataRunnable(JSONObject obj, String url){
|
|
|
23 |
this.obj = obj;
|
|
|
24 |
this.url = url;
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
@Override
|
|
|
28 |
public void run() {
|
|
|
29 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
30 |
try {
|
|
|
31 |
ArrayList<NameValuePair> nameValuePairs = new ArrayList<>();
|
|
|
32 |
nameValuePairs.add(new BasicNameValuePair("pushdata",obj.toString()));
|
|
|
33 |
|
|
|
34 |
HttpPost httppost = new HttpPost(url);
|
|
|
35 |
httppost.setHeader("Authorization", basicAuth);
|
|
|
36 |
|
|
|
37 |
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
|
|
|
38 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
39 |
|
|
|
40 |
} catch (ClientProtocolException e) {
|
|
|
41 |
|
|
|
42 |
} catch (IOException e) {
|
|
|
43 |
|
|
|
44 |
}
|
|
|
45 |
}
|
|
|
46 |
}
|