This is the code which I have written on the app side, which is being developed using Xamarin
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(ApiUrl);
objRequest.Method = "POST";
objRequest.ContentType = "application/x-www-form-urlencoded";//"application/json;charset=utf-8";
objRequest.Headers.Add("Authentication", "web60134");
UTF8Encoding utf8Encoding = new UTF8Encoding();
byte[] arrRequest;
arrRequest = utf8Encoding.GetBytes(JsonReq);
objRequest.ContentLength = arrRequest.Length;
Stream requestStream = objRequest.GetRequestStream();
requestStream.Write(arrRequest, 0, arrRequest.Length);
requestStream.Close();
HttpWebResponse res = (HttpWebResponse)objRequest.GetResponse();
StreamReader streamReader = new StreamReader(res.GetResponseStream());
string result = streamReader.ReadToEnd();
This is the code written on the server side which is PHP
$recvd = $_POST['TH_ET_LoginProcess'];
$recvdArr = json_decode($recvd);
I tried using file_get_contents("php://input")
but both the methods are returning null or nothing.
What is the best way to read JSON at web server using PHP in such scenario?