简体   繁体   English

Java BlackBerry-如何使用GET方法正确调用php脚本?

[英]Java BlackBerry - How to call a php script properly with GET method?

Hey guys what's up? 大家好吗? I'm making a very simple game for BlackBerry Curve 8520, and i need to get the ranking from the server. 我正在为BlackBerry Curve 8520做一个非常简单的游戏,我需要从服务器获取排名。 In order to get this data, the web programmers gave me php files that gets the data from the database and returns it as a dynamic xml file. 为了获取此数据,Web程序员给了我php文件,该文件从数据库获取数据并将其作为动态xml文件返回。

My question is: 我的问题是:

How can i load that php file using java code? 如何使用Java代码加载该php文件? how can i pass a get parameter to that request? 如何将get参数传递给该请求?

how can i parse the xml retrieved from the php script? 我如何解析从php脚本检索到的xml?

Thanks in advance! 提前致谢!

Francisco 弗朗西斯科

You really have two problems here, and I think you should attempt to address them separately. 您这里确实有两个问题,我认为您应该尝试分别解决它们。

  • Problem 1 is getting the data from the Server 问题1是从服务器获取数据
  • Problem 2 is parsing the data you get from the Server. 问题2是解析从服务器获取的数据。

Both these problems have been covered extensively on this and other forums previously, so I suggest that you search here and elsewhere. 这两个问题之前都已在此论坛和其他论坛上进行了广泛讨论,因此,建议您在此处和其他位置进行搜索。 Here are a few links from SO: 这是来自SO的一些链接:

blackberry HttpConnection.GET 黑莓HttpConnection.GET

Parse XML file on BlackBerry 在BlackBerry上解析XML文件

In addition, I recommend you review the documentation provided on the official BB site: 另外,我建议您查看BB官方网站上提供的文档:

http://developer.blackberry.com/bbos/java/ http://developer.blackberry.com/bbos/java/

including the following: 包括以下内容:

http://developer.blackberry.com/bbos/java/documentation/intro_networking_1984362_11.html http://developer.blackberry.com/bbos/java/documentation/intro_networking_1984362_11.html

As you will see, the BB offers a number of methods of doing communication, in your case I would recommend the ConnectionFactory API: http://developer.blackberry.com/bbos/java/documentation/network_api_1984363_11.html 如您所见,BB提供了许多进行通信的方法,在您的情况下,我建议您使用ConnectionFactory API: http : //developer.blackberry.com/bbos/java/documentation/network_api_1984363_11.html

And here is something on parsing XML: 这是解析XML的一些内容:

http://supportforums.blackberry.com/t5/Java-Development/Use-the-XML-Parser/ta-p/445210 http://supportforums.blackberry.com/t5/Java-Development/Use-the-XML-Parser/ta-p/445210

This should be enough to get you going. 这应该足以使您前进。 Please come back with specific questions if you have issues with any of this. 如果您有任何疑问,请再次提出具体问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM