问题描述
问候,
我想设置从我的黑莓应用程序服务器连接。我能得到回应code对服务器的状态。现在我有,我有张贴到服务器的几个值
它像一个注册页面值(用户名,密码,年龄)都被发送到服务器。
连接工厂connFact =新的ConnectionFactory();
ConnectionDescriptor connDesc;
connDesc = connFact.getConnection(URL);
如果(connDesc!= NULL)
{
HttpConnection的httpConn;
httpConn =(HttpConnection的)connDesc.getConnection();
尝试
{
最终诠释iResponse code = httpConn.getResponse code();
UiApplication.getUiApplication()的invokeLater(Runnable的新()
{
公共无效的run()
{
Dialog.alert(响应code:+ Integer.toString(iResponse code));
}
});
}
赶上(IOException异常E)
{
通信System.err.println(捕获到IOException:+ e.getMessage());
}
}
多数民众赞成在code我曾经得到的回应code。
我想AP preciate,如果有人可以帮助我如何我可以做一个POST请求到服务器..
对于状态的服务器的URL是company.com/app/version/stats
当它注册这将是
company.com/app/register
感谢您
...
httpConn =(HttpConnection的)connDesc.getConnection();
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty(用户名,名);
httpConn.setRequestProperty(密码,通过);
....
Greetings,
I am trying to setup a server connection from my BlackBerry Application . I was able to get a response code on the status of the server. Now i have a few values which i have to POST to the server
Its like a registration page values(username, password, age ) have to be sent to the server .
ConnectionFactory connFact = new ConnectionFactory();
ConnectionDescriptor connDesc;
connDesc = connFact.getConnection(url);
if (connDesc != null)
{
HttpConnection httpConn;
httpConn = (HttpConnection)connDesc.getConnection();
try
{
final int iResponseCode = httpConn.getResponseCode();
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
Dialog.alert("Response code: " + Integer.toString(iResponseCode));
}
});
}
catch (IOException e)
{
System.err.println("Caught IOException: " + e.getMessage());
}
}
Thats the code i used to get the response code.I would appreciate it if someone could help me how i can make a POST request to the server..the server url for status was company.com/app/version/stats
when it for register it would becompany.com/app/register
Thank you
...
httpConn = (HttpConnection)connDesc.getConnection();
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("username",name);
httpConn.setRequestProperty("password",pass);
....
这篇关于黑莓HTTP POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!