I am not able to access the post parameters i'm sending from an android device. From code examples I have been looking at, I'm not sure what I am doing wrong -- any help is appreciated.
Here is my android code:
URL t_url = new URL(urlStr); HttpsURLConnection con = (HttpsURLConnection) t_url.openConnection(); //Create SSL con SSLContext sc; sc = SSLContext.getInstance("TLS"); sc.init(null, null, new java.security.SecureRandom()); con.setSSLSocketFactory(sc.getSocketFactory()); con.setReadTimeout(10000); con.setConnectTimeout(10000); con.setRequestMethod("POST"); con.setDoOutput(true); con.setInstanceFollowRedirects(false); con.setRequestProperty("phone_number", mPhone_number); con.setUseCaches(false); con.connect(); As you can see, I am sending a request property with a phone number.
To try to grab this in PHP, I use this code:
$phone_num = $POST_['phone_number']; To test to see if this is successful, I use:
file_put_contents($file, "Entry: " . $phone_num . "\n", FILE_APPEND | LOCK_EX); My log file is coming up empty, so my guess is that I am not getting the post data correctly from the android device.
If you have any questions about my code or what I am trying to do, please ask and I will elaborate.
Solved my issue by sending them as JSON!
setRequestPropertyyou set a header field Sets the value of the specified request header field. but on PHP side you try to read a post body. Read this stackoverflow.com/questions/20020902/…