【问题标题】:Using Pushme.to to send Push notification to iphone使用 Pushme.to 向 iphone 发送推送通知
【发布时间】:2011-11-25 15:37:28
【问题描述】:

我正在使用http://www.barattalo.it/2010/08/09/send-push-notification-to-iphone-with-php-and-pushme-to/

当我调用该函数时,我会收到错误消息。

Notice: Undefined offset: 1 in <PATH>ServiceDesk.php on line 15

Notice: Undefined offset: 1 in <PATH>ServiceDesk.php on line 15

Notice: Undefined offset: 1 in <PATH>ServiceDesk.php on line 17

这里是代码

function pushMeTo($widgeturl,$text,$signature) {
    $agent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12";
    if (!function_exists("curl_init")) die("pushMeTo needs CURL module, please install CURL on your php.");
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $widgeturl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    $page = curl_exec($ch);
    preg_match("/form action=\"(.*?)\"/", $page, $form_action);
    preg_match("/textarea name=\"(.*?)\"/", $page, $message_field);
    preg_match("/input type=\"text\" name=\"(.*?)\"/", $page, $signature_field);
    $ch = curl_init();
    $strpost = $message_field[1].'=' . urlencode($text) . '&'.$signature_field[1].'=' . urlencode($signature);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $strpost );
    curl_setopt($ch, CURLOPT_URL, $form_action[1]);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    $page = curl_exec($ch);
}


$url = "<MY URL HERE>";
 pushmeTo ($url,"This Is A Test","ServiceDesk");

我以前从未使用过 CURL,但我可以使用 PHP。

我怀疑这可能是代理问题,但我只能在每个脚本的基础上设置代理。谁能告诉我如何在这个脚本中使用 CURL 设置代理。

谢谢,

【问题讨论】:

    标签: php iphone curl push-notification


    【解决方案1】:

    $form_action[1] 未定义(意味着您的 $form_action 数组中的索引 1 处没有任何内容),所以我会在第一个 curl_exec 之后查看$page,以及这里的正则表达式preg_match("/form action=\"(.*?)\"/", $page, $form_action);


    编辑

    再看一遍,看起来你所有的正则表达式都失败了,所以再看看$page 并确保正则表达式返回的所有值都是你需要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-21
      • 1970-01-01
      • 2011-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多