Esempio n. 1
0
function test_initAppIoscert($name, $description, $release_cert, $dev_cert)
{
    global $apiKey;
    global $secretKey;
    $channel = new Channel($apiKey, $secretKey);
    //注意百度push服务对ios dev版与ios release版采用不同的域名.
    //如果是dev版请修改push服务器域名"https://channel.iospush.api.duapp.com", release版则使用默认域名,修改域名使用setHost接口
    //$channel->setHost("https://channel.iospush.api.duapp.com");
    $ret = $channel->initAppIoscert($name, $description, $release_cert, $dev_cert);
    if (false === $ret) {
        error_output('WRONG, ' . __FUNCTION__ . ' ERROR!!!!');
        error_output('ERROR NUMBER: ' . $channel->errno());
        error_output('ERROR MESSAGE: ' . $channel->errmsg());
        error_output('REQUEST ID: ' . $channel->getRequestId());
    } else {
        right_output('SUCC, ' . __FUNCTION__ . ' OK!!!!!');
        right_output('result: ' . print_r($ret, true));
    }
}
Esempio n. 2
0
function test_initAppIoscert($name, $description, $release_cert, $dev_cert)
{
    global $apiKey;
    global $secretKey;
    $channel = new Channel($apiKey, $secretKey);
    //如果ios应用当前部署状态为开发状态,指定DEPLOY_STATUS为1,默认是生产状态,值为2.
    //旧版本曾采用不同的域名区分部署状态,仍然支持。
    //$optional[Channel::DEPLOY_STATUS] = 1;
    $ret = $channel->initAppIoscert($name, $description, $release_cert, $dev_cert);
    if (false === $ret) {
        error_output('WRONG, ' . __FUNCTION__ . ' ERROR!!!!');
        error_output('ERROR NUMBER: ' . $channel->errno());
        error_output('ERROR MESSAGE: ' . $channel->errmsg());
        error_output('REQUEST ID: ' . $channel->getRequestId());
    } else {
        right_output('SUCC, ' . __FUNCTION__ . ' OK!!!!!');
        right_output('result: ' . print_r($ret, true));
    }
}
 static function initBaiduCertIOS($notifyMsg)
 {
     global $channels;
     $channel = ChannlesMap::getChannel($notifyMsg->appid . '_' . $notifyMsg->restkey);
     if ($channel !== false && $channel != null) {
         return $channel;
     }
     $channel = new Channel($notifyMsg->appid, $notifyMsg->restkey);
     // 请正确设置apiKey和secretKey,在开发者中心应用基本信息中查看
     $channel->setHost('https://channel.iospush.api.duapp.com');
     $fd = fopen(dirname(__FILE__) . "/baidu/cert/" . $notifyMsg->iosCertPath, 'r');
     $dev_cert = fread($fd, filesize(dirname(__FILE__) . "/baidu/cert/" . $notifyMsg->iosCertPath));
     // 开发版APNs pem证书
     // var_dump($fd);
     $fd_release = fopen(dirname(__FILE__) . "/baidu/cert/" . $notifyMsg->iosCertPathRel, 'r');
     $release_cert = fread($fd_release, filesize(dirname(__FILE__) . "/baidu/cert/" . $notifyMsg->iosCertPathRel));
     // 开发版APNs pem证书
     // var_dump(dirname( __FILE__)."/baidu/cert/".$notifyMsg->iosCertPathRel);
     //  var_dump(dirname( __FILE__)."/baidu/cert/".$notifyMsg->iosCertPath);
     $ret = $channel->initAppIoscert('yongqing li (95XW9X94ZC)', 'ios certification', $release_cert, $dev_cert);
     // cert_name和cert_des您自定义字符串即可
     if (false === $ret) {
         var_dump('initBaiduCertIOS fail.');
         var_dump($channel->errmsg());
     } else {
         var_dump('initBaiduCertIOS succ.');
         ChannlesMap::setChannel($notifyMsg->appid . '_' . $notifyMsg->restkey, $channel);
     }
     return $channel;
 }