标签:
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]);
}
标签:
原文地址:http://www.cnblogs.com/yuanxiaoping_21cn_com/p/4874748.html