2013-02-11 84 views
0

我想为我的uni的门户创建一个android应用程序。令人惊讶的是,麦格理大学没有一个。 现在我已经创建了一个简单的登录用户界面,学生/员工ID文本框和密码字段。和“登录”按钮如何发送用户名和密码从android到ASP页

我知道如何从两个文本字段中检索文本,但是如何将用户标识和密码发送到asp服务器页面并检索下一页并检索并显示它。

页是https://portal.sibt.nsw.edu.au/Default.asp

我使用HTTP POST发送登录名气。

HttpClient client = new DefaultHttpClient(); 
HttpPost post = new HttpPost("https://portal.sibt.nsw.edu.au/Default.asp"); 

的AVD崩溃每次都尝试执行此命令

HttpResponse response = client.execute(post); 

注:这是一个try/catch()块。

我不知道为什么它每次都会崩溃。

回答

0

您需要将HttpPost发送到https://portal.sibt.nsw.edu.au/Default.asp?Summit=OK
你可以发现哪些参数被发送:
- 按F12
- - 选择“网络”
- 与谷歌浏览
打开你的网站,不要忘记检查“保留日志uppon导航”

祝你好运!

+0

感谢您的帮助,我似乎无法理解如何发送与httpPost ID和密码。将能告诉我你 – Sabbib 2013-02-12 05:08:59

+0

有十亿的例子,如果你谷歌的“Android HttpPost”:http://foobarpig.com/android-dev/http-post-example-submiting-a-simple-form.html上 – EvZ 2013-02-12 09:04:50

+0

更新进度。 – Sabbib 2013-02-12 09:46:32

0
this is how you can send username and password and recieve the response 

public class callASPX 
{ 
     public static final String URL = "http://localhost:8080/appName/actionOrServletTobeCalled"; 
    public static void main(String args[]) 
    { 
     callASPXobj = new callASPX(); 
     String username = "username"; 
     String password = "password"; 
     obj.getOutputFromUrl(URL+"?username="+username+"&password="+password); 

    } 
    public String getOutputFromUrl(String url) 
    { 
     HttpClient httpClient = new DefaultHttpClient(); 
     HttpPost httpPost = new HttpPost(url); 
     HttpResponse response; 
     StringBuilder builder= new StringBuilder(); 
     BufferedReader in = new BufferedReader(new       InputStreamReader(response.getEntity().getContent(), "UTF-8")); 
     char[] buf = new char[8000]; 
     int l = 0; 
      while (l >= 0) 
      { 
       builder.append(buf, 0, l); 
       l = in.read(buf); 
      } 
     return builder.toString(); 
    } 
} 
相关问题