我正在使用PHP构建App Engine应用程序,但是当我尝试连接到GCM服务器时,它返回以下错误:
解析错误:语法错误,意外' $ data' (T_VARIABLE),期待')'第6行
我正在使用此代码...
$gcm_regid = "kjfadlfk;dkf;fpoekfldfk;";
$url = "https://android.googleapis.com/gcm/send";
$data = ['data' => 'this', 'registration_ids' => $gcm_regid];
$data = http_build_query($data);
$context = [
'https' => [
'method' => 'POST',
'header' => "Content-Type: application/json\r\n" .
"Authorization: key=" . GOOGLE_API_KEY . "\r\n",
'content' => $data
]
];
$context = stream_context_create($context);
$result = file_get_contents($url, false, $context);