user3739757 user3739757 - 1 year ago 170
Android Question

PHP API Content-Type: application/json. Response empty data

Works fine for:

  • Sending from Android platform to PHP (web service)

  • Request headers sent with this
    Content-Type: application/x-www-form-urlencoded

Not working for:

  • Request headers sent with
    Content-Type: application/json
    . no data is received

API is working on same platform but not in cross platform:

  • Web to web WORKING

  • Android to web NOT WORKING

In PHP added both header on top:

header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');

Answer Source

after log search i found my answer.. we need this function to get $_POST response from cross platform (android to web)


OR we can also use this function to get $_POST response


here is complete function to get the response.

$data = urldecode(file_get_contents('php://input'));
echo $data;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download