简体   繁体   English

带CURL的PHP​​后八位字节流

[英]PHP post octet stream with CURL

I try to follow this sample in PHP https://msdn.microsoft.com/library/windows/apps/xaml/hh868252.aspx 我尝试在PHP https://msdn.microsoft.com/library/windows/apps/xaml/hh868252.aspx中遵循此示例

What will be the equivalent of this peace of code in PHP? PHP中这种和平的代码等效于什么?

byte[] contentInBytes = Encoding.UTF8.GetBytes(xml);
...
using (Stream requestStream = request.GetRequestStream())
            requestStream.Write(contentInBytes, 0, contentInBytes.Length);

If i try this, this is not working 如果我尝试这个,这是行不通的

$sendPush = curl_init();
curl_setopt($sendPush, CURLOPT_URL, $uri);  
curl_setopt($sendPush, CURLOPT_HEADER, true);
$headers = array('Content-Type: text/xml',"Content-Type: text/xml","X-WNS-RequestForStatus:true", "X-WNS-Type:wns/toast","Content-Length: " . strlen($toastMessage) ,"X-WindowsPhone-Target: toast","Authorization: Bearer $accessToken");
curl_setopt($sendPush, CURLOPT_HTTPHEADER, $headers);
curl_setopt($sendPush, CURLOPT_RETURNTRANSFER, true);
curl_setopt($sendPush,CURLOPT_POST, true);
curl_setopt($sendPush, CURLOPT_POSTFIELDS, $toastMessage);
$output = curl_exec($sendPush);

Thanks for your help 谢谢你的帮助

The problem wasn't from CURL but from the $toastMessage string. 问题不是来自CURL,而是来自$ toastMessage字符串。 If you want to send WPS notifications, you need to use one of the format describe here https://msdn.microsoft.com/en-us/library/windows/apps/hh761494.aspx?f=255&MSPPError=-2147217396 如果要发送WPS通知,则需要使用此处描述的一种格式https://msdn.microsoft.com/zh-cn/library/windows/apps/hh761494.aspx?f=255&MSPPError=-2147217396

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM