I'm trying to send JSON data over to a PHP service. This is the code that I have to transmit the data over:
public class TransmitRegistrationData extends AsyncTask<JSONObject, JSONObject, JSONObject> {
String url = "http://kreationware.com/phpimp/RegistrationDataReceiver.php";
@Override
protected JSONObject doInBackground(JSONObject... data) {
JSONObject json = data[0];
try {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppostreq = new HttpPost(url);
StringEntity se = new StringEntity(json.toString());
se.setContentType("application/json;charset=UTF-8");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json;charset=UTF-8"));
httppostreq.setEntity(se);
HttpResponse httpresponse = httpclient.execute(httppostreq);
} catch (Exception e) { e.printStackTrace(); }
return json;
}
}
And I'm populating and building said JSON data as such
public void buildRegistrationData(String data){
try{
jsonObject.put("registration_data", data);
registrationJsonObject.put("registration_information", jsonObject);
}catch (JSONException e){
e.printStackTrace();
}
}
Where String data is what the user inputs. Yet I keep receiving an empty array on the PHP side. Any clue where I'm going wrong?