I am looking for PHP equivalent of the below code even if it is not a compilable code just providing the high level functions to use to perform each of these functionality would be great.
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"];
So basically I am looking for PHP equivalent of the following
- Send an Async request with some custom headers and content type and send it async/stream
- create a payload in byte from the string
- get the response and look at the headers.