Advertisement
Guest User

Push php

a guest
Apr 20th, 2013
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. <?php
  2. // unique device url
  3. $deviceURL = 'http://sn1.notify.live.net/throttledthirdparty/01.00/AAEvDeBgje2pQLQH3cXfiGWFAgAAAAADAQAAAAQUZm52OjIzOEQ2NDJDRkI5MEVFMEQ';
  4.  
  5. // tile data
  6. $imageURL = "/images/about-main.png";
  7. $count = rand(0,99);
  8. $title = "Push del server!";
  9. $text = "Pushata dal server";
  10. $page="/SecondPage.xaml?NavigatedFrom=ToastNotification";
  11.  
  12. $headers  = array("X-WindowsPhone-Target: token","X-NotificationClass: 1");
  13. $msg = "<?xml version=\"1.0\" encoding=\"utf-8\"?>".
  14.        "<wp:Notification xmlns:wp=\"WPNotification\">".
  15.             "<wp:Tile>".
  16.                 "<wp:BackgroundImage>".$imageURL."</wp:BackgroundImage>".
  17.                 "<wp:Count>".$count."</wp:Count>".
  18.                 "<wp:Title>".$title."</wp:Title>".
  19.             "</wp:Tile>".
  20.        "</wp:Notification>";
  21.  
  22. // use Client URL Library
  23. $ch = curl_init();
  24. // set an options for a cURL transfer
  25. // look options here:  http://www.php.net/manual/en/function.curl-setopt.php
  26. // and what are needed here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202970(v=vs.92).aspx
  27. curl_setopt($ch, CURLOPT_URL, $deviceURL);
  28. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  29. curl_setopt($ch, CURLOPT_POST, true);
  30. curl_setopt($ch, CURLOPT_HEADER, true);
  31. curl_setopt($ch, CURLOPT_HTTPHEADER,$headers + array('Content-Type: text/xml','Accept: application/*'));
  32. curl_setopt($ch, CURLOPT_POSTFIELDS, $msg);
  33. // perform a cURL session
  34. curl_exec($ch);
  35. // close a cURL session
  36. curl_close($ch);
  37.  
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement