Created
June 22, 2017 17:33
-
-
Save CodingTricksHub/a787c3cf6cb86de1f15d802be74569ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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