我正在编写一个 php 脚本以将通知发送到 CGM 服务器,并且我正在使用以下示例:
public function send_notification($registatoin_ids, $message) { // 包含配置 include_once './config.php';
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => $registatoin_ids,
'data' => $message,
);
$headers = array(
'Authorization: key=' . GOOGLE_API_KEY,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
// Close connection
curl_close($ch);
echo $result;
}
但我不确定变量的值应该是什么: CURLOPT_POSTFIELDS 、 CURLOPT_SSL_VERIFYPEER 、 CURLOPT_RETURNTRANSFER 、 CURLOPT_HOST 、 CURLOPT_URL
有人会碰巧知道这些值应该是什么吗?
谢谢!