As I am not familiar with curl, Could anyone pointed out where I got wrong? db_connect.php has 5 lines, so line 16 is curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);. What's wrong about this line? If it is correct which line of the code causes the error?
<?
require "db_connect.php";
function send_rival_ID($rival_token,$rival_ID){
$url = "https://fcm.googleapis.com/fcm/send";
$fields = array("registration_ids"=>$rival_token, "data"=>$rival_ID);
$headers = array("Authorization:key = AIzaSyD33y6r4V96sdqaRSS7g4UeIh7vUfZhQYM", "Content-Type: application/json");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOP_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
if($result === FALSE){
die("Curl fail: " . curl_error($ch));
}
curl_close($ch);
return $result;
}
...
if($result2->num_rows > 0){
$sql3 = "UPDATE battle SET player2 = '$user_ID', player2_status = 'not_ready', player2_token = '$token', player1_status = 'not_ready' WHERE room_ID = '$room_ID'";
$result3 = $conn->query($sql3);
$sql3 = "SELECT * FROM battle WHERE room_ID = '$room_ID'";
$result3 = $conn->query($sql3);
$row3 = $result3->fetch_assoc();
echo $row3["player1"];
send_rival_ID($row3["player1_token"],$row3["player1"]);
}