Hello guys I’m trying to sending my JSONArray to php page
I’m getting HTTP//1.1 200 but I still can’t show it in my php page and I still didn’t know I have succeed to send it or not
here is my android code
public void sendJson() {
HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); //Timeout Limit
HttpResponse response;
try{
HttpPost post = new HttpPost("http://sap-sp-test.dff.jp/sp.php/ranking/index");
Log.i("entry", MixiActivity.entry.toString());
ArrayList<NameValuePair> nVP = new ArrayList<NameValuePair>(2);
nVP.add(new BasicNameValuePair("json", MixiActivity.entry.toString()));
post.setEntity(new UrlEncodedFormEntity(nVP));
response = client.execute(post);
Log.i("postData", response.getStatusLine().toString());
}
catch(Exception e){
e.printStackTrace();
Log.i("error", e.getMessage());
}
}
PHP code
$data = $_POST['json'];
echo $data;
I already tried some example here but I still can’t sent the data
and the JSON array(MixiActivity.entry) is not empty
when I try to print it with log,the log show the right value of the JSON array
but I just can’t send it to the PHP
please help me with this problem
Thanks a lot
Niko
Finally I gave up with http post in android
now I’m using javascript to get the jsonarray from android
with this
public class JavaScriptInterface {
Context mContext;
and in the HTML
for the post to PHP I’m using form POST in the javascript
and in the PHP for receiving the json
and this method works for me
anyway thanks mariachi for your help