将数据从手机传递到 PHP
$title = $_POST['title'];
$message = $_POST['message'];
$token = $_POST['token'];
// ---- уведомление для трея ---- //
$payload = '{
"to" : '$token',
"notification" : {
"title" : '$title',
"body" : '$message',
"sound": "notify"
}
}';
给出错误信息
PHP 解析错误:语法错误,意外的 '$token' (T_VARIABLE)
从手机本身我这样传输
class SendPostReqAsyncTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("token", token));
nameValuePairs.add(new BasicNameValuePair("title", title));
nameValuePairs.add(new BasicNameValuePair("message", message_ban));
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(ServerURL);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
return "Data Inserted Successfully";
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
Toast.makeText(ActivityAdmin.this, "Data Submit Successfully", Toast.LENGTH_LONG).show();
}
}
SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();
sendPostReqAsyncTask.execute(token, title, message_ban);
我该如何解决这个问题或至少检查它是否有效?
更正的引用:
您应该已经阅读了错误,然后它就会变得清晰
这个标记出现在结束引号之后,应该嵌套。