English 中文(简体)
服务器数据
原标题:Android server data fetching

I would like to fetch data from a phpMyAdmin server. The only function I know, is this :

private String getPage() {
            String str = "***";

            try
            {
                HttpClient hc = new DefaultHttpClient();
                HttpPost post = new HttpPost("http://mywebsite.me");
                HttpResponse rp = hc.execute(post);

                if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
                {
                    str = EntityUtils.toString(rp.getEntity());
                }
            }catch(IOException e){
                e.printStackTrace();
            }  

            return str;
        }

由于我需要用用户名和密码来认证自己,这并不成功。 我认为,这一职能不会奏效的另一个原因是,它占用了该网页的源头(ctrl+u,在“ Chrome”中,以及我所需要的数值,这些数值列在服务器上。 我如何能够这样做?

最佳回答

你回过头来,我认为这是错误的。 我假定,phpAdmin实际上是 phpmyadmin,你正在从你的数据库中查阅数据?

PHPMyAdmin is a selection of pages that does what you want to do for a browser: extract information from a database. You don t need to go trough that page to get the info. You can either write some .php files that extract the data for you (for instance in XML or JSON) and fetch them with above code, or try to contact you database directly, without intervention of the apache server.

Edit:它看起来像直接接触是太容易的,而且你在外部连接方面应当有效(可能不是这样)。 我猜测,你应写出所谓的“REST”接口(一个档案库,基本上做什么,但并不像复杂:你要求一张桌子,没有别的“Sandmyadmin”)。

http://www.helloandroid.com/tutorials/jointing-mysql-database"rel=“nofollow”http://www.helloandroid.com/tutorials/jointing-mysql-database

问题回答

我不知道你是否愿意回答,但直截了当的方式是建立一个有问询的实验室档案,以提取你在数据库中所需要的数据,并从实验室档案中以xml或json格式输出数据。 如果你需要一个实例:

http://webdesignergeeks.com/mobile/android/android-login-authentication-with-remote-db/ it shows you how to get data from database in php and how to make a http request from the android app.

后者向服务器申请异狄氏剂,以获取所需数据。 用户名称和密码。 您指的是SSL证书。 用户名和密码究竟需要什么?

如果您的网站需要认证,则使用活页头添加器(Wafox)或丝网,以捕捉目前仍在运行的POST申请,则使用该圆顶来获取来源(即假设,如果u成功地贴上 ,则该网页将显示来自Mitoper(一个 子)的数据),然后查找该来源,以发现你们所需要的价值。

举例来说,这种联系也应当如此。

http://mywebsite.me?login=true&username=myusername&password=mypassword&extrafield=xxx....

页: 1

 HttpPost post = new HttpPost("http://mywebsite.me?login=true&username=myusername&password=mypassword&extrafield=xxx....");

P.S :我不了解和刺roid,但一般解决办法如下:





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签