php - curl_setopt() expects parameter 2 to be long, string on line 16
Get the solution ↓↓↓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"]);
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: object of class stdclass could not be converted to string
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.