繁体   English   中英

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

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

我有一个PHP脚本(从此处获取 ),用于将APNS通知发送到iOS应用程序,但是该应用程序的Web服务是用C#/ ASP.Net编写的。

我已经设法在服务器上安装PHP并从命令行测试了脚本,但是不知道如何从Web服务中执行此操作(即使可能的话)。

有没有一种方法可以从ASP.Net中运行PHP文件,还是最好用C#重写PHP脚本?

CNC中需要更深入地打开了这个 ,这促使我尝试下面的代码,但没有成功:

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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM