php - Curl:Unknown SSL protocol error gcm -
enter image description herei have designed gcm server in php(mamp). curl version-7.43.0,php version 7.0.0 .the code 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 try running php script in browser shows following error
curl failed: unknown ssl protocol error in connection gcm-http.googleapis.com:443
i have disabled ssl verification,still shows curl error.
changing ssl version 6 worked me.
curl_setopt($ch,curlopt_sslversion,6);
Comments
Post a Comment