我有一个存储在 Xampp 服务器中的 php 脚本,并希望我的应用程序执行它来执行任务。在 Eclipse 中,服务器端的 android.txt 没有发生任何事情。以下是我的android应用程序代码
String url = "http://my.site.php?data=hello";
HttpClient client = new DefaultHttpClient();
try {
client.execute(new HttpGet(url));
} catch(IOException e) {
//do something here
}
Run Code Online (Sandbox Code Playgroud)
以下是我在服务器端的 php 代码。
$name=$_GET['data'];
$file=fopen("./android.txt","w");
fwrite($file, $name);
fclose($file);
Run Code Online (Sandbox Code Playgroud)
虽然我从 mozila 浏览器运行 php,但它运行良好。但此代码不适用于 android。