黑莓发送HTTPPost要求 [英] Blackberry send a HTTPPost request
本文介绍了黑莓发送HTTPPost要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发和应用黑莓,我需要一个HTTP POST请求发送到我的服务器。我使用模拟器,以测试我的应用程序,我发现这code以发送请求:
i am developing and app for blackberry and i need to send a Http Post Request to my server. I'm using the simulator in order to test my app and i found this code in order to send request:
的http://vasudevkamath.techfiz.com/general/posting-data-via-http-from-blackberry/
但我不能得到它的工作,因为它在这一行失败:
But i can't get it work, because it fails in this line:
int rc = _httpConnection.getResponseCode();
你知道吗?
感谢
推荐答案
下面是关于如何发送POST请求的样本code:
Here is a sample code on how to send a POST request:
HttpConnection c = (HttpConnection) Connector.open(url, Connector.READ_WRITE);
c.setRequestMethod(HttpConnection.POST);
OutputStream os = c.openOutputStream();
os.write(request.getBytes("UTF-8"));
os.flush();
os.close();
InputStream is = c.openInputStream();
只要确保你在一个单独的线程中使用这个code。
Just make sure you use this code in a separate thread.
这篇关于黑莓发送HTTPPost要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文