curl_setopt()期望参数2为long,第16行为string

时间:2016-08-20 04:05:26

标签: php curl

由于我不熟悉卷曲,有人能指出我错在哪里吗? db_connect.php有5行,所以第16行是curl_setopt($ ch,CURLOPT_SSL_VERIFYPEER,false);.这条线路有什么问题?如果正确哪行代码导致错误?

<?
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"]);
}

0 个答案:

没有答案