复制代码 代码如下:
<?php
//php需要开启ssl(OpenSSL)支持
$apnsCert = "ck.pem";//连接到APNS时的证书许可文件,证书需格外按要求创建
$pass = "123456";//证书口令
$serverUrl = "ssl://gateway.sandbox.push.apple.com:2195";//push服务器,这里是开发测试服务器
$deviceToken = "a8fcd4aa8943b223d4ebcd54fe168a8b99b3f24c63dbc0612db25a8c0a588675";//ios设备id,中间不能有空格,每个ios设备一个id
$message = $_GET ['message'] or $message = "hello!";
$badge = ( int ) $_GET ['badge'] or $badge = 2;
$sound = $_GET ['sound'] or $sound = "default";
$body = array('aps' => array('alert' => $message , 'badge' => $badge , 'sound' => $sound));
$streamContext = stream_context_create();
stream_context_set_option ( $streamContext, 'ssl', 'local_cert', $apnsCert );
stream_context_set_option ( $streamContext, 'ssl', 'passphrase', $pass );
$apns = stream_socket_client ( $serverUrl, $error, $errorString, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $streamContext);//连接服务器
if ($apns) {
echo "Connection OK <br/>";
} else {
echo "Failed to connect $errorString";
return;
}
$payload = json_encode ( $body );
$msg = chr(0) . pack('n', 32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack('n', strlen($payload)) . $payload;
$result = fwrite ( $apns, $msg);//发送消息
fclose ( $apns );
if ($result)
echo "Sending message successfully: " . $payload;
else
echo 'Message not delivered';
?>
<?php
//php需要开启ssl(OpenSSL)支持
$apnsCert = "ck.pem";//连接到APNS时的证书许可文件,证书需格外按要求创建
$pass = "123456";//证书口令
$serverUrl = "ssl://gateway.sandbox.push.apple.com:2195";//push服务器,这里是开发测试服务器
$deviceToken = "a8fcd4aa8943b223d4ebcd54fe168a8b99b3f24c63dbc0612db25a8c0a588675";//ios设备id,中间不能有空格,每个ios设备一个id
$message = $_GET ['message'] or $message = "hello!";
$badge = ( int ) $_GET ['badge'] or $badge = 2;
$sound = $_GET ['sound'] or $sound = "default";
$body = array('aps' => array('alert' => $message , 'badge' => $badge , 'sound' => $sound));
$streamContext = stream_context_create();
stream_context_set_option ( $streamContext, 'ssl', 'local_cert', $apnsCert );
stream_context_set_option ( $streamContext, 'ssl', 'passphrase', $pass );
$apns = stream_socket_client ( $serverUrl, $error, $errorString, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $streamContext);//连接服务器
if ($apns) {
echo "Connection OK <br/>";
} else {
echo "Failed to connect $errorString";
return;
}
$payload = json_encode ( $body );
$msg = chr(0) . pack('n', 32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack('n', strlen($payload)) . $payload;
$result = fwrite ( $apns, $msg);//发送消息
fclose ( $apns );
if ($result)
echo "Sending message successfully: " . $payload;
else
echo 'Message not delivered';
?>
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年11月20日
2024年11月20日
- 模拟之声慢刻CD《声入人心[年度发烧人声严选]》[低速原抓WAV+CUE]
- 陈致逸《幻想乐园 Fantasyland》[FLAC/分轨][554.27MB]
- Rhymist / LusciousBB《年轮》[320K/MP3][76.52MB]
- Rhymist / LusciousBB《年轮》[FLAC/分轨][410.02MB]
- 群星《歌手2024 第11期》[320K/MP3][93.88MB]
- 群星《歌手2024 第11期》[FLAC/分轨][496.06MB]
- 群星《国风超有戏 第7期》[320K/MP3][30.73MB]
- 模拟之声慢刻CD《试音天品8[女声低音炮]》[低速原抓WAV+CUE]
- 群星《抖烧第三季DSD》[低速原抓WAV+CUE]
- [ABC]蔡琴《百万琴歌[6N纯银镀膜]》[低速原抓WAV+CUE]
- 群星《国风超有戏 第7期》[FLAC/分轨][147.99MB]
- 群星《闪光的夏天 第3期》[320K/MP3][61.94MB]
- 群星《闪光的夏天 第3期》[FLAC/分轨][336MB]
- 【迷幻电音】Elea-2024-Hypnos(FLAC)
- 【民族融合】VA-2024-TheOrientCollective:GoldenSand(FLAC)