zoukankan      html  css  js  c++  java
  • php苹果原生apns推送接口

    转自: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!"; } }
  • 相关阅读:
    (01)Docker简介
    Gym-101242B:Branch Assignment(最短路,四边形不等式优化DP)
    2019牛客暑期多校训练营(第三场)G: Removing Stones(启发式分治)
    POJ
    高维前缀和
    HDU
    BZOJ
    HDU
    POJ
    Gym-100648B: Hie with the Pie(状态DP)
  • 原文地址:https://www.cnblogs.com/zinging/p/15633342.html
Copyright © 2011-2022 走看看