HttpWebRequest uyumsuz bu. Net / C # kodu PHP eşdeğer, özel ikili yükü ve yanıtları analiz başlıklarını

0 Cevap

Sadece bu işlevselliğinin her gerçekleştirmek için kullanmak üst düzey fonksiyonları sağlayan bir Derlenebilir kod olmasa bile ben aşağıda kod PHP eşdeğer arıyorum harika olurdu.


        string subscriptionUri = "sample.com";
        HttpWebRequest sendNotificationRequest = (HttpWebRequest)WebRequest.Create(subscriptionUri);
        sendNotificationRequest.Method = "POST";

        sendNotificationRequest.Headers.Add("X-MessageID", "<UUID>");
        sendNotificationRequest.ContentType = "text/xml";


        sendNotificationRequest.ContentLength = notificationMessage.Length;
        byte[] notificationMessage = new byte[] {<payload>};

        using (Stream requestStream = sendNotificationRequest.GetRequestStream())
        {
           requestStream.Write(notificationMessage, 0, notificationMessage.Length);
        }

        // Sends the notification and gets the response.
        HttpWebResponse response = (HttpWebResponse)sendNotificationRequest.GetResponse();
        string notificationStatus = response.Headers["X-NotificationStatus"];
        string notificationChannelStatus = response.Headers["X-SubscriptionStatus"];
        string deviceConnectionStatus = response.Headers["X-DeviceConnectionStatus"];  

Böylece temelde aşağıdaki PHP eşdeğer arıyorum

  1. Bazı özel başlıkları ve içerik türü ile uyumsuz isteği göndermek ve uyumsuz / akışı göndermek
  2. dizeden bayt bir yük oluşturmak
  3. yanıt almak ve başlıkları bakmak.

0 Cevap