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!"; } }
  • 相关阅读:
    codeforces 1012C
    openjudge 6045:开餐馆
    openjudge 7624:山区建小学
    codevs 1040 统计单词个数
    openjudge9267:核电站
    openjudge7624:山区建小学
    bzoj3224:普通平衡树
    洛谷1137:旅行计划
    洛谷1095:守望者的逃离
    校内模拟赛:确定小组
  • 原文地址:https://www.cnblogs.com/zinging/p/15633342.html
Copyright © 2011-2022 走看看