我试图从一个PHP服务器的Android反编译应用程序读取数据。我用wireshark
了解应用程序发送的数据类型,其结果是:从Android使用php读取json数据
{“initType”:“第一时间”,“参数”:真正的“细节”:...... ..........}
我试图捕捉到了这个数据,并在此PHP代码文件中插入它们:正确生成
<?php
$json = $_POST["initType"];
$decoded = json_decode($json, TRUE);
if ($decoded === FALSE) {
throw new Exception('Bad JSON format.');
}
$file_handle = fopen('tmp.json', 'w');
fwrite($file_handle, $decoded);
fclose($file_handle);
?>
的文件,但它是空的。什么是错误?
为什么你解码,然后序列化?你不能直接写'$ json'吗? –
'json_decode()'将它变成一个数组。你应该'fwrite($ file_handle,$ json);'而不是。 – alizahid
什么是“反编译的Android应用程序”? – njzk2