MoonAPNS(以前是:从ASP.Net/C#中运行PHP脚本?)


MoonAPNS (was:Run a PHP script from within ASP.Net/C#?)

我有一个PHP脚本(取自此处)来向iOS应用程序发送APNS通知,但该应用程序的web服务是用C#/ASP.Net.编写的

我已经设法在服务器上安装了PHP,并从命令行测试了脚本,但不知道如何在web服务中做到这一点(甚至不知道这是否可能)。

有没有一种方法可以在ASP.Net中运行PHP文件,或者我最好尝试用C#重新编写PHP脚本?

-编辑-更多的搜索发现了这一点,这促使我尝试以下代码,但没有成功:

public void PushNotificationAlert()
{
    string call = @"""php.exe""";
    string param1 = @"-f";
    string param2 = @"""~'APNS'myPush.php""";
    Process myProcess = new Process();
    ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(call);
    myProcessStartInfo.UseShellExecute = false;
    myProcessStartInfo.RedirectStandardOutput = true;
    myProcessStartInfo.Arguments = string.Format("{0} {1}", param1, param2);
    myProcess.StartInfo = myProcessStartInfo;
    myProcess.Start();
    StreamReader myStreamReader = myProcess.StandardOutput;
}

如果有人仍然感兴趣,这是我在Moon中使用的最终有效的代码:

// use MoonAPNS to send push notification
NotificationPayload payload = new NotificationPayload(deviceToken, message, badge, "default");
var notificationList = new List<NotificationPayload>() { payload };   
PushNotification push = new PushNotification(true, p12file, p12pass);
var result = push.SendToApple(notificationList);