2
我想在Safari扩展中运行PHP bot函数。如何在Safari扩展中使用cURL代码运行PHP脚本?
这是我试图放在一起的HTML代码,但它是PHP,cURL和HTML的混乱,我不知道我在做什么。
我从未尝试使用cURL,然后从http://www.barattalo.it/2010/08/09/send-push-notification-to-iphone-with-php-and-pushme-to/获得此代码,并且在我尝试启动$ ch时,似乎扩展停止工作。这显然破坏了代码的整个目的,因为我需要它来运行cURL命令。
为获得此应用程序的任何技巧?
function performCommand(event)
{ if (event.command === "sendLink") {
pushMeTo($u,$t,$s); }
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";
$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);
}
请重新格式化您的问题? – 2010-08-13 22:18:07
你得到的错误是什么?我相信它会告诉你发生了什么...... – 2010-08-13 22:19:02
你知道你不能从客户端,即扩展所在的地方调用PHP,对吧? – zneak 2010-08-13 22:19:35