<?php
define('PW_AUTH', '3x1x7MEguZSVIaUVHdBG4XXXXXXXXXXXXXXXXXXXXXXXXXXXxgfHPPAMqmX1VmYH5k6GFYo8n0QdmexUSQRWpvoFYwVACAnG');
define('PW_APPLICATION', '2XXFX-XXx7C');
define('PW_DEBUG', true);
function pwCall($method, $data = array()) {
$url = 'https://cp.pushwoosh.com/json/1.3/' . $method;
$request = json_encode(['request' => $data]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if (defined('PW_DEBUG') && PW_DEBUG) {
print "[PW] request: $request'n";
print "[PW] response: $response'n";
print "[PW] info: " . print_r($info, true);
}
}
pwCall('createMessage', array(
'application' => PW_APPLICATION,
'auth' => PW_AUTH,
'notifications' => array(
array(
'send_date' => 'now',
'content' => 'Send this content to user',
)
),
)
);
?>
PHP告诉我有一个错误
解析错误:语法错误,第 8 行/home/a5047433/public_html/pushtest.php 中出现意外的"[",预期")"
当我在 PHP 测试器上运行它时,它如何说它没问题,并且正如预期的那样担心任何机构都知道问题是什么
我在 http://phpfiddle.org/测试了这段代码,它按预期工作
我正在获取的错误:解析错误:语法错误,意外的"[",预期")"这是在 000 网络主机上的帐户任何帮助都非常感谢,谢谢
是的,短数组语法只是从 PHP 5.4 开始。因此,请仔细检查此VHost使用的php(只需在其中放入phpinfo)。
顺便说一句,这是一个非常旧的版本;你应该尽快更新。
为了逃避此错误,您需要编写源代码,通过编码风格不短,如果数组和过度构造
array(
'key' => 'value'
)
// don't use ['key' => 'value'] is not correct
if(expression) {
// blablabla
} else {
//blablabla
}
// don't use expression?'':''
如果你使用完整的结构,你会看到每个{}和每个[]和上面的符号,这很容易理解。如果你在团队中工作,你的同事不理解你的代码。