I'm having problems updating my live tiles using PHP via Push Notifications. For normal Toast Message there wasn't any error. But when I tried using the same coding, and change the phone target as well as the notification class. I got a payload error. Here's my source code, and wondering if I did something wrong.
Thanks!
<?php
if( isset($_POST['push_action']) && $_POST['push_action'] == "1") {
$tileMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
"<wp:Notification xmlns:wp=\"WPNotification\">" .
"<wp:Tile>" .
"<wp:BackgroundImage>" . $_POST["push_msg0"] .
"</wp:BackgroundImage>" +
"<wp:Count>" . $_POST["push_msg1"] . "</wp:Count>" +
"<wp:Title>" . $_POST["push_msg2"] . "</wp:Title>" +
"<wp:BackBackgroundImage>" . $_POST["push_msg3"] . "</wp:BackBackgroundImage>" +
"<wp:BackTitle>" . $_POST["push_msg4"] . "</wp:BackTitle>" +
"<wp:BackContent>" . $_POST["push_msg5"] . "</wp:BackContent>" +
"</wp:Tile> " .
"</wp:Notification>";
// Create request to send
$r = curl_init();
curl_setopt($r, CURLOPT_URL, $_POST["push_uri"]);
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: token',
'Accept: application/*', 'X-NotificationClass: 1','Content-Length:'.strlen($tileMessage));
curl_setopt($r, CURLOPT_HTTPHEADER, $httpHeaders);
// add message
curl_setopt($r, CURLOPT_POSTFIELDS, $tileMessage);
// execute request
$output = curl_exec($r);
curl_close($r);
}
?>
<form method="post" action="push2.php">
<h3>Push through php</h3>
<input type="text" name="push_uri" id="push_uri" placeholder="Push Uri" style="width:50%;padding:5px;" autofocus required/> <br><br>
<input type="text" name="push_msg0" id="push_msg0" placeholder="Background Image" style="width:50%;padding:5px;" required/> <br><br>
<input type="text" name="push_msg1" id="push_msg1" placeholder="Count" style="width:50%;padding:5px;" required/> <br><br>
<input type="text" name="push_msg2" id="push_msg2" placeholder="Title" style="width:50%;padding:5px;" required/> <br><br>
<input type="text" name="push_msg3" id="push_msg3" placeholder="Back Background Image" style="width:50%;padding:5px;" required/> <br><br>
<input type="text" name="push_msg4" id="push_msg4" placeholder="Back Title" style="width:50%;padding:5px;" required/> <br><br>
<input type="text" name="push_msg5" id="push_msg5" placeholder="Back Content" style="width:50%;padding:5px;" required/> <br><br>
<input type="hidden" name="push_action" value="1" />
<input type="submit" value="Push" style="width:50%;padding:5px;"/>
Apparently I missed out the Version=2.0, Tile ID & Tile template that caused it not to work. Here's the updated for those 2 lines, after that I was able to update the tiles via push notifications.
"<wp:Notification xmlns:wp=\"WPNotification\" Version=\"2.0\">"
"<wp:Tile Id=\"/MainPage.xaml?Name=flip\" Template=\"FlipTile\">"