Public Function Actionnotifyto () {
$regid = $_request[' Regid ');
$url = ' Https://api.jpush.cn/v3/push '; The Platform service address of the calling interface
$post _string = Array (' Platform ' = ' all ', ' audience ' =>array ());
$str = ' {' Platform ': ' All ', ' audience ': {
"registration_id": ["010157BBEB5"]
}, "notification": {"alert": "You have a new message!"}} ';
$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]);
}
PHP uses Curl to invoke the Jpush interface for message push