我想知道如何查看curl并找出PHP中的哪些regIds因某种原因无效,以便我可以从服务器中删除它们。我还在测试,我故意把两个坏的和一个好的,所以我得到一个成功和两个失败,我如何让脚本找到失败?
<?php
function sendNotification($title ,$message , $registrationIds)
{
require_once'config.php';
$msg = array
(
'message' => $message,
'title' => $title
);
$feilds = array
(
'registration_ids' => $registrationIds,
'data' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
#Sending the packet
curl_setopt($ch, CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
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($feilds));
$result = curl_exec($ch);
$err = curl_errno($ch);
curl_close($ch);
if ( !$result )
{
echo "<br />";
echo "Error: ' $err'";
}
return $result;
}
?>