Receber os dados enviados via POST no php

17/01/2020

0

PHP

Boa tarde galera.

Sou novo em programação e estou com o seguinte problema. Preciso receber os dados no PHP que são enviados via POST em uma aplicação C#. Este é o codigo da aplicação C# que envia os dados via metodo POST.


public void sendTagsToWeb(TagDatabase tagdb)
        {
            DateTime now = DateTime.Now;
            string tagData = string.Empty;
            Dispatcher.Invoke(new ThreadStart(delegate()
            {
                lock (tagdb)
                {
                    tagData = tagData + "reader_Name=" + HttpPostServiceReaderName + "&mac_address=" + GetMACAddress() + "&line_ending=\n" + "&field_delim=,"
                             + "&field_names=" + GetFieldNames() + "&field_values=";
                    for (int i = 0; i < tagdb.UniqueTagCount; i++)
                    {
                        tagData = tagData + GetFieldValues(tagdb.TagList[i]);
                    }
                }
            }));
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(HttpPostServiceUrl);
                request.Method = "POST";
                request.ProtocolVersion = HttpVersion.Version11;
                byte[] byteArray = Encoding.UTF8.GetBytes(tagData);
                request.ContentType = "application/x-www-form-urlencoded";
                request.ContentLength = byteArray.Length;
                request.Proxy = null;
                //By making Expect100Continue as false client will not expect 100-continue response from server.
                //By doing so we can send large amounts of data over the network.
                System.Net.ServicePointManager.Expect100Continue = false;
                using (Stream dataStream = request.GetRequestStream())
                {
                    dataStream.Write(byteArray, 0, byteArray.Length);
                    dataStream.Flush();
                    dataStream.Close();
                }
                var response = request.GetResponse() as HttpWebResponse;
                response.Close();
                request.Abort();
                request = null;
                DateTime end = DateTime.Now;
                if (Convert.ToDouble(end.Subtract(now).TotalMilliseconds) < HttpPostInterval)
                    HttpPostDispatchTimer.Interval = HttpPostInterval - Convert.ToDouble(end.Subtract(now).TotalMilliseconds);
                else
                    HttpPostDispatchTimer.Interval = 1;
                HttpPostDispatchTimer.Enabled = true;
            }
            catch (Exception ex)
            {
                HttpPostDispatchTimer.Enabled = false;
                HttpPostDispatchTimer.Close();
                MessageBox.Show("HttpPost:" + ex.Message, "Universal Reader Assistant Message", MessageBoxButton.OK, MessageBoxImage.Error);
                broadcastOFF();
            }
        }

Porém quando tento receber os dados do POST na url que direcionei, não recebo nada

url usada = localhost/sistema/data/desenvolvimento/teste.php
Equipamento é uma leitora RFID ThingMagic Edge50.

Atenciosamente
Mauricio Piva

Mauricio Piva

Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar