[英]PHP post octet stream with CURL
我嘗試在PHP https://msdn.microsoft.com/library/windows/apps/xaml/hh868252.aspx中遵循此示例
PHP中這種和平的代碼等效於什么?
byte[] contentInBytes = Encoding.UTF8.GetBytes(xml);
...
using (Stream requestStream = request.GetRequestStream())
requestStream.Write(contentInBytes, 0, contentInBytes.Length);
如果我嘗試這個,這是行不通的
$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);
謝謝你的幫助
問題不是來自CURL,而是來自$ toastMessage字符串。 如果要發送WPS通知,則需要使用此處描述的一種格式https://msdn.microsoft.com/zh-cn/library/windows/apps/hh761494.aspx?f=255&MSPPError=-2147217396
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.