public function actionNotifyto() {
//$regid = $_REQUEST[‘regid‘];
$url = ‘https://api.jpush.cn/v3/push‘; //调用接口的平台服务地址
//$post_string = array(‘platform‘=>‘all‘,‘audience‘=>array());
$str = ‘{"platform":"all","audience":{
"registration_id" : [ "010157bbeb5" ]
},"notification":{"alert":" 您有新的消息!"}}‘;
$header = array(
‘Content-Type: application/json‘,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERPWD, "1fe46801b7e1bc98bc65a964:c85db6c8c5180a4b5b563dd0");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$result = curl_exec($ch);
curl_close($ch);
return json_encode([‘e‘=>0, ‘r‘=>$result]);
}