卷曲:未知的SSL协议错误gcm

enter image description hereI have designed gcm server in php(MAMP). curl version-7.43.0,php version 7.0.0 .The code for server-

<?php



function send_push_notification($registration_id,$message){
    define('API_KEY','AIzaSyAoFih8qEFlOis3vVWhsxxlLxxxxxxxxxx');
    $url='https://gcm-http.googleapis.com/gcm/send';

    $fields=array(
        'registration_id'=>$registration_id,
        'data'=>$message,
        );
    $headers=array(
        'Authorization:key='.API_KEY,
        'Content-Type:application/json'
        );

    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

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

        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSLVERSION, 3);



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

        // Close connection
        curl_close($ch);
        echo $result;
 }



?>
<?php
send_push_notification("e2DgrsZPGKU:APA91bF_73a6-o5CLV-gdcZzYFAbtikJqi-5w6gDSCaRa4z8-1iGLeV5SS6hQkW8pj_g_DxBe7JLDsOPMGu3y1GkKw1vpn_ZEWIeCwbSITpd0pLwaz50W8uzHKNghvnf1xxxxxxxxxxx","hi");
?>

When I try running this php script in my browser it shows following error

Curl failed: Unknown SSL protocol error in connection to gcm-http.googleapis.com:443

I have disabled SSL verification,still it shows curl error.

Changing SSL version to 6 worked for me.

curl_setopt($ch,CURLOPT_SSLVERSION,6);