Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.codingtrickshub.checkboxlistview.serverCalls;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.util.ArrayList;
public class InsertUpdateFavouriteCategories {
public static String insertUpdateCall(String categoriesCsv) {
String response = "";
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://xxx.xxx.x.xxx:(port)/CheckBoxListView/insertUpdateFavouriteCategories.php");
try {
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("email", "tutorials@codingtrickshub.com"));
nameValuePairs.add(new BasicNameValuePair("favouriteCategories", categoriesCsv));
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse httpResponse = httpClient.execute(httpPost);
response = EntityUtils.toString(httpResponse.getEntity());
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.