title: Windows 8 PHP push notifications
body: <p>Is it currently supported that I send toast push notifications to a Windows 8 store app using php server side script like on Windows Phone.</p>
  
  <p>I was able to find the below php code to send push notifications to a Windows 8 store app but doesn't seem to support toast notifications.</p>
  
  <pre><code>&lt;?php
  class WPNTypesEnum{       
  const Toast = 'wns/toast';
  const Badge = 'wns/badge';
  const Tile  = 'wns/tile';
  const Raw   = 'wns/raw';
  }                         
  
  class WPNResponse{
  public $message = '';
  public $error = false;
  public $httpCode = '';
  
  function __construct($message, $httpCode, $error = false){
      $this-&gt;message = $message;
      $this-&gt;httpCode = $httpCode;
      $this-&gt;error = $error;
  }
  }
  
  class WPN{            
  private $access_token = '';
  private $sid = '';
  private $secret = '';
  
  function __construct($sid, $secret){
      $this-&gt;sid = $sid;
      $this-&gt;secret = $secret;
  }
  
  private function get_access_token(){
      if($this-&gt;access_token != ''){
          return;
      }
  
      $str = "grant_type=client_credentials&amp;client_id=$this-&gt;sid&amp;client_secret=$this-&gt;secret&amp;scope=notify.windows.com";
      $url = "https://login.live.com/accesstoken.srf";
  
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
      curl_setopt($ch, CURLOPT_POSTFIELDS, "$str");
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      $output = curl_exec($ch);
      curl_close($ch);                       
  
      $output = json_decode($output);
  
      if(isset($output-&gt;error)){
          throw new Exception($output-&gt;error_description);
      }
  
      $this-&gt;access_token = $output-&gt;access_token;
  }
  
  public function build_tile_xml($title, $img){
      return '&lt;?xml version="1.0" encoding="utf-16"?&gt;'.
      '&lt;tile&gt;'.
        '&lt;visual lang="en-US"&gt;'.
          '&lt;binding template="TileWideImageAndText01"&gt;'.
            '&lt;image id="1" src="'.$img.'"/&gt;'.
            '&lt;text id="1"&gt;'.$title.'&lt;/text&gt;'.
          '&lt;/binding&gt;'.
        '&lt;/visual&gt;'.
      '&lt;/tile&gt;';
  }
  
  public function post_tile($uri, $xml_data, $type = WPNTypesEnum::Tile, $tileTag = ''){
      if($this-&gt;access_token == ''){
          $this-&gt;get_access_token();
      }
  
      $headers = array('Content-Type: text/xml', "Content-Length: " . strlen($xml_data), "X-WNS-Type: $type", "Authorization: Bearer $this-&gt;access_token");
      if($tileTag != ''){
          array_push($headers, "X-WNS-Tag: $tileTag");
      }
  
      $ch = curl_init($uri);
      # Tiles: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868263.aspx
      # http://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
      curl_setopt($ch, CURLOPT_VERBOSE, 1);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      $output = curl_exec($ch);
      $response = curl_getinfo( $ch );
      curl_close($ch);
  
      $code = $response['http_code'];
      if($code == 200){
          return new WPNResponse('Successfully sent message', $code);
      }
      else if($code == 401){
          $this-&gt;access_token = '';
          return $this-&gt;post_tile($uri, $xml_data, $type, $tileTag);
      }
      else if($code == 410 || $code == 404){
          return new WPNResponse('Expired or invalid URI', $code, true);
      }
      else{
          return new WPNResponse('Unknown error while sending message', $code, true);
      }
  }
  }
  ?&gt;
  </code></pre>