Php 使用Pushme.to向iphone发送推送通知
我正在使用 当我调用该函数时,会收到错误消息Php 使用Pushme.to向iphone发送推送通知,php,iphone,curl,push-notification,Php,Iphone,Curl,Push Notification,我正在使用 当我调用该函数时,会收到错误消息 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 注意:第15行Service
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
注意:第15行ServiceDesk.php中未定义的偏移量:1
注意:第15行ServiceDesk.php中未定义的偏移量:1
注意:第17行ServiceDesk.php中未定义的偏移量:1
这是密码
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");
函数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”;
如果(!function_存在(“curl_init”))die(“pushMeTo需要curl模块,请在php上安装curl”);
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$widgeturl);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_USERAGENT,$agent);
$page=curl\u exec($ch);
预匹配(“/form action=\”(.*?\”/”,$page,$form\u action);
预匹配(“/textarea name=\”(*?\”/”,$page,$message\u字段);
preg\u match(“/input type=\”text\”name=\”(.*?\“/”,$page,$signature\u字段);
$ch=curl_init();
$strpost=$message_字段[1].='.urlencode($text)。&'$signature_字段[1].='.urlencode($signature);
curl_setopt($ch,CURLOPT_POSTFIELDS,$strpost);
curl_setopt($ch,CURLOPT_URL,$form_action[1]);
卷曲设置($ch,卷曲设置桩,1);
curl_setopt($ch,CURLOPT_头,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_USERAGENT,$agent);
$page=curl\u exec($ch);
}
$url=”“;
pushmeTo($url,“这是一个测试”,“服务台”);
我以前从未使用过CURL,但我对PHP没问题
我怀疑这可能是一个代理问题,但我只允许在每个脚本的基础上设置代理。有人能告诉我如何在这个脚本中使用CURL设置代理吗
谢谢,
$form\u action[1]
是未定义的(意思是在$form\u action数组的索引1中没有任何内容),所以我会在第一次curl\u exec之后查看$page
,在这里的regexpreg\u匹配(“/form action=\”(.?\”/“,$page,$form\u action”)代码>
编辑
再看一眼,您的所有正则表达式似乎都失败了,因此再次查看$page
和allso make shure正则表达式返回的所有值都是您需要的