我有一个PHP脚本(取自here)来向iOS应用程序发送an通知,但该应用程序的web服务是用C#/ASP.Net编写的。
我已经设法在服务器上安装了PHP,并从命令行测试了脚本,但我不知道如何在web服务中做到这一点(或者即使这是可能的)。
有没有办法在ASP.Net中运行PHP文件,或者尝试用C#重写PHP脚本会更好?
-EDIT-一些更多的搜索出现了this,这促使我尝试以下代码,但没有成功:
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;
}发布于 2013-02-15 19:45:01
如果有人仍然感兴趣,这是我在月球上使用的代码,最终起作用了:
// 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);https://stackoverflow.com/questions/14812041
复制相似问题