0

I am trying to send data to my server using HttpPost via the following code.

private boolean FacebookLogin(String url) {
    boolean isDataSend = false;

    try {
        HttpClient client = new DefaultHttpClient();
        HttpPost request = new HttpPost(url);

        List<NameValuePair> value = new ArrayList<NameValuePair>();

        value.add(new BasicNameValuePair("data", FacebookData()));

        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(value);
        request.setEntity(entity);

        HttpResponse res = client.execute(request);

        if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            String bufstring = EntityUtils.toString(res.getEntity(),
                    "UTF-8");
            isDataSend = true;
        }

    } catch (Exception e) {

    }
    return isDataSend;
}

Is there any way i can have a look at how the $_POST looks on the server end. so that it will be easier for me to code the server part.

2 Answers 2

1

You can write the received $_POST on a file. Sometimes I do that. It's not the most elegant solution, but it works fine.

1
  • 1
    file_put_contents('test-output.txt', $output = print_r($_POST, true));
    – fonini
    Nov 10, 2011 at 10:41
1

Try using a http proxy (e.g. Fiddler) for debugging, it helps a lot in these cases. You can set up an emulator to use this proxy for network communications, so you can inspect the messages sent and received. Check out the emulator docs on how to configure it to use a proxy.

1
  • i am debugging from the phone. any idea how i can intercept that :P
    – Harsha M V
    Nov 10, 2011 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.