“晚风吹人醒 万事藏于心 
        我没说不公平 也没说苦 我说我知道了”
转自:http://www.xinghuiblog.com/393.html

public
function c_push(){ if(defined('CURL_HTTP_VERSION_2_0')){ $device_token = '413eed6b6253f16fdc010217caa845cadab7abde6360ee959051dc3b6645a06b'; //$pem_file = 'path to your pem file'; $pem_file = "/Users/xzh/www/test/www/pem/dev.pem"; //$pem_secret = 'your pem secret'; $pem_secret = ''; //$apns_topic = 'your apns topic. Can be your app bundle ID'; $apns_topic = 'com.zhapp.fhzxg.BPushProject'; $data = array( "aps"=>array( 'alert'=>'这是推送标题', "sound"=>"default", "badge"=>0, ), 'app'=>array( "title"=>"这是展示标题内容", "content"=>"这是自定义内容", ), ); $url = "https://api.development.push.apple.com/3/device/$device_token"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POSTFIELDS, $j = json_encode($data)); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "apns-topic: $apns_topic", )); curl_setopt($ch, CURLOPT_SSLCERT, $pem_file); curl_setopt($ch, CURLOPT_SSLKEYTYPE, 'PEM'); curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $pem_secret); $response = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($httpcode == 200){ echo "push ok"; } }else{ echo "error http2!"; } }

 

posted on 2021-12-02 15:16  诗里刻画的影子  阅读(252)  评论(0编辑  收藏  举报