我想在我的黑莓應用程序中啓動一些線程,這取決於我從php獲取的響應。爲此,我想發送變量,就像我們在將URL參數從java發送到php時使用的那樣。這可以做到嗎?從php通信到java /使用黑莓手機獲取參數
-1
A
回答
0
試試這個代碼 -
String httpURL="http://www.your_url.com/login.php?username=123&password=123";
HttpConnection httpConn;
httpConn = (HttpConnection) Connector.open(httpURL);
httpConn.setRequestMethod(HttpConnection.POST);
DataOutputStream _outStream = new ataOutputStream(httpConn.openDataOutputStream());
byte[] request_body = httpURL.getBytes();
for (int i = 0; i < request_body.length; i++) {
_outStream.writeByte(request_body[i]);
}
DataInputStream _inputStream = new DataInputStream(
httpConn.openInputStream());
StringBuffer _responseMessage = new StringBuffer();
int ch;
while ((ch = _inputStream.read()) != -1) {
_responseMessage.append((char) ch);
}
String res = (_responseMessage.toString());
編輯 -
,如果你得到響應喜歡JSON考慮,然後將下面的代碼將幫助你分析它。 {"status":"100" "id":"123"}
JSONObject json = new JSONObject(res);
String status=json.getString("status");
String id=json.getString("id");
0
你需要做一個HTTP調用到PHP的服務,你會得到一個迴應相應的處理之後,你應該從Apache的HTTP客戶端去,這將幫助你:How to call and pass the parameters to the Servlet using the Java class in my swing application?
相關問題
- 1. 從黑莓手機使用HttpCore
- 2. 從黑莓手機上讀取Cookies
- 3. 如何刪除黑莓手機短信?
- 4. 黑莓手機信號塔位置
- 5. 黑莓手機:如何使用PersistableRIMKeyStore?
- 6. 如何從黑莓手機中的URL獲取HTML源代碼
- 7. 安排黑莓手機通知
- 8. 使用黑莓手機上傳圖片
- 9. 獲取通過GPS黑莓
- 10. json解析黑莓手機?
- 11. 黑莓手機間隙
- 12. 黑莓手機模擬器
- 13. 黑莓手機在黑莓手機中的簽名應用程序?
- 14. 黑莓手機的facebook api
- 15. 黑莓手機中的Httpconnection
- 16. 如何在黑莓手機
- 17. 黑莓手機上的WebSql
- 18. 黑莓手機應用程序正在研究黑莓手機平板電腦?
- 19. 黑莓:(JAVA)發佈/獲取數據
- 20. 黑莓手機應用程序開發
- 21. 在黑莓手機上加載黑莓應用程序
- 22. 如何獲取黑莓手機玩家簽名的CSJ文件?
- 23. 通過無線通信從黑莓到winform應用程序
- 24. 爲黑莓手機運營商獲取MCC和MNC
- 25. 如何獲取黑莓新手柄的信息
- 26. 以往的黑莓手機Eclipse插件
- 27. 從sqlite中獲取數據在黑莓手機中速度很慢
- 28. 黑莓手機簽名應用程序
- 29. 黑莓手機中的SAP PO認證
- 30. 要在黑莓手機上獲取模塊名稱
創建一個HTTP連接,然後郵寄/從/到URL獲得DATAS。 – Signare 2013-02-27 12:19:41
謝謝Signare。你能否給我提供一些例子。我是新來的PHP。謝謝。 – catherine 2013-02-27 13:01:28