Get the authentication from the moodle for a android application

走远了吗. 提交于 2019-12-13 05:22:33

问题


I want to get the authentication from moodle (say the moodle site from our university) in my android application. And I do not have the access to the database. I tried to make a http post request from my application with username and password.

But when I execute the post request, I get an exception. This is what I have tried

private URI url = new URI("https://online.mrt.ac.lk/login/index.php"); 
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); 
nameValuePairs.add(new BasicNameValuePair("username", "user")); 
nameValuePairs.add(new BasicNameValuePair("password", "password"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();

I get a exception like this

javax.net.ssl.SSLPeerUnverifiedException: No peer certificate

Please someone help me.

来源:https://stackoverflow.com/questions/18086716/get-the-authentication-from-the-moodle-for-a-android-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!