Sen android kullanarak aşağıdaki koddan dize olarak Json veri gönderebilir:
BufferedReader reader = null;
// Send data
try {
/* forming th java.net.URL object */
URL url = new URL(this.url);
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestProperty("Content-Type", "application/json");
urlConnection.setRequestProperty("Accept", "application/json");
urlConnection.setRequestMethod("POST");
urlConnection.connect();
/* pass post data */
byte[] outputBytes = jsonData.toString().getBytes("UTF-8");
OutputStream os = urlConnection.getOutputStream();
os.write(outputBytes);
os.close();
/* Get Response and execute WebService request*/
int statusCode = urlConnection.getResponseCode();
/* 200 represents HTTP OK */
if (statusCode == HttpsURLConnection.HTTP_OK) {
inputStream = new BufferedInputStream(urlConnection.getInputStream());
ResponseData= convertStreamToString(inputStream);
} else {
ResponseData = null;
}
ve php, aşağıdaki kodu ekleyerek verileri alabilirsiniz:
$post_body = file_get_contents('php://input');
$post_body = iconv('UTF-8', 'UTF-8//IGNORE', utf8_encode($post_body));
$reqData[] = json_decode($post_body);
$postData = $reqData[0];
echo $postData->name;
bazı code..it göstermek olacak problemi bulmak için yardım –