0
我送一個JSON數組服務器:PHP - 接收JSON(POST)
{
"Name":"Number",
"Name":"Number"
, ...
}
我怎樣才能得到它的PHP?
發送方法是POST。
這裏是我的Android代碼:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://192.168.1.7/admina/contacts_inout.php");
String json = "";
json = jsons.toString();
StringEntity se = new StringEntity(json);
httpPost.setEntity(se);
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type", "application/json");
HttpResponse httpResponse = httpclient.execute(httpPost);
您可以使用[php:// input](http://php.net/manual/en/wrappers.php.php#wrappers.php.input)閱讀原始文章(因爲您沒有發佈表單字段) )。一個簡單的使用/例子是'if(getenv('REQUEST_METHOD')=='POST'){$ data = file_get_contents(「php:// input」); }' –
@KraangPrime你的意思是:file_get_contents(「php:// input」); ? – Ghorbanzadeh
是的。請閱讀我最後一次聲明的編輯(和上次修改時間) –