我是一名网络开发人员 (PHP)。我想使用 PHP 搜索 Windows Phone 7 的推送通知,但结果始终是 .NET。
请有人可以帮助我。
更新:如何一次发送多个设备?因为延迟时间在 1 秒左右,所以如果我有 1000 个设备要推送,我可能需要等待 1000 秒。
我是一名网络开发人员 (PHP)。我想使用 PHP 搜索 Windows Phone 7 的推送通知,但结果始终是 .NET。
请有人可以帮助我。
更新:如何一次发送多个设备?因为延迟时间在 1 秒左右,所以如果我有 1000 个设备要推送,我可能需要等待 1000 秒。
以下是向 URL“ _URL_TO_SEND_TO_ ”发送 toast 通知的 PHP 代码,该 URL是从 MPNS 接收到的令牌:
<?php
// Create the toast message
$toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
"<wp:Notification xmlns:wp=\"WPNotification\">" .
"<wp:Toast>" .
"<wp:Text1>" . "SendToast" . "</wp:Text1>" .
"<wp:Text2>" . "Text Message" . "</wp:Text2>" .
"</wp:Toast> " .
"</wp:Notification>";
// Create request to send
$r = curl_init();
curl_setopt($r, CURLOPT_URL,_URL_TO_SEND_TO_);
curl_setopt($r, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($r, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, true);
// add headers
$httpHeaders=array('Content-type: text/xml; charset=utf-8', 'X-WindowsPhone-Target: toast',
'Accept: application/*', 'X-NotificationClass: 2','Content-Length:'.strlen($toastMessage));
curl_setopt($r, CURLOPT_HTTPHEADER, $httpHeaders);
// add message
curl_setopt($r, CURLOPT_POSTFIELDS, $toastMessage);
// execute request
$output = curl_exec($r);
curl_close($r);
?>
如果这是您需要的代码,请检查此答案。
您不需要在.NET 中实现它。您只需将正确的 XML 有效负载发送到手机提供的 URL。
查看这篇关于在 Windows Phone 7 上实现推送通知的文章。
基本步骤是: