Hello Developers,
If you want to send push notification from PHP website to a windows app or windows phone displayed as Toast. Write below function in any php file and save this file :
<?php
function makeWebRequest($url, $msg, $value1, $value2)
{
//the actual data
$toastMessage = "<?xml version='1.0' encoding='utf-8'?>" .
"<wp:Notification xmlns:wp='WPNotification'>" .
"<wp:Toast>" .
"<wp:Text1>".$value1."</wp:Text1>" .
"<wp:Text2>".$msg."</wp:Text2>" .
"<wp:Param>/AgentChat.xaml?agentId=".$value2."&notif=true</wp:Param>" .
"</wp:Toast>" .
"</wp:Notification>";
$r = curl_init();
curl_setopt($r, CURLOPT_URL,$url);
curl_setopt($r, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($r, CURLOPT_POST, true);
curl_setopt($r, 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);
}
?>
2. $toastMessage = get many parameter as you want to throw with this notification, so you can get this from your windows app developer.
For any query please free to contact with me.
If you want to send push notification from PHP website to a windows app or windows phone displayed as Toast. Write below function in any php file and save this file :
<?php
function makeWebRequest($url, $msg, $value1, $value2)
{
//the actual data
$toastMessage = "<?xml version='1.0' encoding='utf-8'?>" .
"<wp:Notification xmlns:wp='WPNotification'>" .
"<wp:Toast>" .
"<wp:Text1>".$value1."</wp:Text1>" .
"<wp:Text2>".$msg."</wp:Text2>" .
"<wp:Param>/AgentChat.xaml?agentId=".$value2."&notif=true</wp:Param>" .
"</wp:Toast>" .
"</wp:Notification>";
$r = curl_init();
curl_setopt($r, CURLOPT_URL,$url);
curl_setopt($r, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($r, CURLOPT_POST, true);
curl_setopt($r, 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);
}
?>
Function Parameter :
1. $url : Every windows phone have a unique url for identity. So kindly tell your windows app team to send that url and you can save it in your user table. When you want to send notification get this url from user table and pass it as first argument of function.2. $toastMessage = get many parameter as you want to throw with this notification, so you can get this from your windows app developer.
For any query please free to contact with me.
Comments
Post a Comment