加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 卷曲失败:OpenSSL SSL_connect:SSL_ERROR_SYSCALL与Cod

发布时间:2020-12-13 13:20:24 所属栏目:PHP教程 来源:网络整理
导读:我将Fire-base Notification CRUL Code与Codeigniter集成在一起.有时我会收到错误,但不是所有时间. 我已将下面的代码集成到控制器中 控制器代码 $newDate=Date('m-d-Y H:i:s');$test_str=$user-us_name. ' Clocked at '.$newDate;$res = array();$res['data'
我将Fire-base Notification CRUL Code与Codeigniter集成在一起.有时我会收到错误,但不是所有时间.

我已将下面的代码集成到控制器中

控制器代码

$newDate=Date('m-d-Y H:i:s');

$test_str=$user->us_name. ' Clocked at '.$newDate;
$res = array();

$res['data']['title'] = $user->us_name.' - Clocked In';
$res['data']['is_background'] = "TRUE";
$res['data']['message'] = $test_str;
$res['data']['image'] = 'http://api.androidhive.info/images/minion.jpg';
$res['data']['payload'] = 'individual';
$res['data']['timestamp'] = date('Y-m-d G:i:s');
$res['data']['act_tab'] = 0;


$cur_id1=$this->db->query("Select token from devices")->result();

foreach($cur_id1 as $cur_id) {

    $fields = array('to' => $cur_id->token,'data' => $res);
    $this->notif_model->sendPushNotification($fields);
}

型号代码

function sendPushNotification($fields) {


        // Set POST variables
        $url = 'https://fcm.googleapis.com/fcm/send';

        $headers = array(
            'Authorization: key=MyServerKey','Content-Type: application/json'
        );
        // Open connection
        $ch = curl_init();

        // Set the url,number of POST vars,POST data
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_POST,true);
        curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);

        // Disabling SSL Certificate support temporarly
        curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);

        curl_setopt($ch,CURLOPT_POSTFIELDS,json_encode($fields));

        // Execute post
        $result = curl_exec($ch);
        if ($result === FALSE) {
            die('Curl failed: ' . curl_error($ch));
        }

        // Close connection
        curl_close($ch);

        return $result;
    }

在运行此时有时我会收到错误

Curl failed: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to fcm.googleapis.com:443

尝试添加 curl_setopt($ch,CURLOPT_SSLVERSION,3);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读