im passing json array as follows in android. Here is the code below
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("tag", request_tag));
if(data.moveToFirst())
{
do
{
params.add(new BasicNameValuePair("iscomplete[]",data.getString(0)));
params.add(new BasicNameValuePair("uidUser[]",data.getString(1)));
params.add(new BasicNameValuePair("connectID[]",data.getString(2)));
}while(data.moveToNext());
}
response = jsonParser.getJSONFromUrl(requestUrl, params);
Toast.makeText(context, response, 10000).show();
now i want to receive it on server side bt it wont work on php
if ($tag == 'request')
{
$complete = (array)$_POST['iscomplete[]'];
$uiuser = (array)$_POST['uidUser[]'];
$connectId = (array)$_POST['connectID[]'];
echo $complete//This gives a blank value
}
json code is as follows
public String getJSONFromUrl(String url, List<NameValuePair> params) {
// Making HTTP request
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
response=EntityUtils.toString(httpEntity);
Log.d("Response",response);
//jObj=new JSONObject(response);
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
On echoing the toast i get an empty message. I think i have not received the data properly
$local_array_of_object = json_decode($POST['incomingjsonarray']);