代码不适用于 wampserver
Code does not works on wampserver
我正在尝试在 wampserver 上发送推送通知,但无法正常工作。
只有当我将它上传到主机服务器时我才工作..
我已经尝试删除并重新安装 wamp。
When the code is running on host server,
I'm getting this message:{"result":true} {"result":true} finished!
and on Wamp I doesnt get any message.
<form action='' method='POST'>
<input type='text' name='text' />
<input type='submit' name='sub'/>
</form>
<?php
if(isset($_POST['sub'])){
$text = $_POST['text'];
$APPLICATION_ID = "xxx";
$REST_API_KEY = "xxx";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'objectId' => array('$in' => array('e594OcnrBe'))
),
'data' => array(
'alert' => $text,
'uri' => 'www.walla.com',
),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
echo $result;
print_r($result);
die('finished!');
}
?>
谢谢!
有效!
我输入了这段代码:
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
我正在尝试在 wampserver 上发送推送通知,但无法正常工作。 只有当我将它上传到主机服务器时我才工作..
我已经尝试删除并重新安装 wamp。
When the code is running on host server, I'm getting this message:{"result":true} {"result":true} finished! and on Wamp I doesnt get any message.
<form action='' method='POST'>
<input type='text' name='text' />
<input type='submit' name='sub'/>
</form>
<?php
if(isset($_POST['sub'])){
$text = $_POST['text'];
$APPLICATION_ID = "xxx";
$REST_API_KEY = "xxx";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'objectId' => array('$in' => array('e594OcnrBe'))
),
'data' => array(
'alert' => $text,
'uri' => 'www.walla.com',
),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
echo $result;
print_r($result);
die('finished!');
}
?>
谢谢!
有效! 我输入了这段代码:
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);