使用php发送Windows Phone 7的推送通知 [英] send push notification for windows phone 7 using php

查看:58
本文介绍了使用php发送Windows Phone 7的推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个Web开发人员(PHP).我想使用PHP搜索到Windows Phone 7的推送通知,但结果始终是.NET.

I'm a web developer (PHP). I would like to searching for push notification to windows phone 7 using PHP but the result is always .NET.

请有人可以帮助我.

更新:如何一次发送多设备?因为延迟时间约为1秒,所以如果我要推入1000个设备,则可能需要1000秒才能等待.

UPDATE : How to send multi-devices at once? because the delay time is around 1 second, so if I have 1000 devices to push, I may need 1000 seconds to wait.

推荐答案

以下是用于向URL" _URL_TO_SEND_TO _ "发送敬酒通知的PHP代码:

The following is the PHP code to send a toast notification to the URL "_URL_TO_SEND_TO_" which is the token received from the 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);
  ?>  

如果这是您需要的代码,请检查此答案.

If this is the code you need, please check this answer.

这篇关于使用php发送Windows Phone 7的推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆