Android HTTPGET HTTPPOST -

时间:2013-03-21 04:31:03

标签: android http http-get

我正在尝试从Android运行php脚本。我尝试了1000种方法,没有任何作用。有什么好主意吗? 我不在乎使用GET或POST,我只是想让它工作T_T 使用Web浏览器(http://www.myweb.net/mail.php?mail=ineed@help.net&pass=123456)可以工作,但没有安卓项目...

最简单的: // Android

HttpPost httppost;
HttpClient httpclient;
try {
httppost = new HttpPost(
"http://www.myweb.net/mail.php?mail=ineed@help.net&pass=123456");
httpclient = new DefaultHttpClient();
httpclient.execute(httppost);
} catch (Exception e) {
}

// PHP

if(isset($_GET['mail']) && isset($_GET['pass'])){
    mail($_GET['mail'],"remember",$_GET['pass']);
}else {
    echo "=(";
}

if(isset($_POST['mail']) && isset($_POST['pass'])){
    mail($_POST['mail'],"remember",$_POST['pass']);
}else {
    echo "=(";
}

谢谢,

我用:

<uses-permission android:name="android.permission.INTERNET" />

和:

<uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="17" />

1 个答案:

答案 0 :(得分:1)