所以我正在尝试使用 php 通过 GCM 向 chrome 扩展发送消息。
$data = json_encode(array(
'channelId' => 'channel id here',
'subchannelId' => '0',
'payload'=>'test'
));
$ch = curl_init();
$curlConfig = array(
CURLOPT_URL => "https://www.googleapis.com/gcm_for_chrome/v1/messages",
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $data,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . $access_token,
'Content-Type: application/json'
)
);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
每个请求都返回 { "error": { "code": 500, "message": null } }。谢谢。