HTTP POST与黑莓 [英] http post with blackberry

查看:145
本文介绍了HTTP POST与黑莓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立在我的黑莓应用程序的HTTP POST。我已经成功地在我相应的Andr​​oid应用程序来实现这一点,所以我知道它的工作找到服务器。我尝试了好几种不同的东西,我没有真正得到错误,它只是在服务器上的信息没有得到更新。我已经看过这篇文章:
黑莓 HTTP POST,和其他几个人。我发现他们有帮助的,但他们最终还是没有解决我的问题。同样,我不明白的错误,但服务器没有更新。这是我目前使用code:

I am trying to set up an http post in my Blackberry app. I have successfully implemented this in my corresponding Android app, so I know the server it working find. I have tried several different things, and I'm not really getting errors, its just the info on the server is not getting updated. I have looked at this post: Http POST in BlackBerry, and several others. I found them helpful, but they didn't ultimately solve my problem. Again, I don't get errors, but the server doesn't get updated. Here is the code I am currently using:

String url = "http://xxxx.com/ratings/add?;deviceside=true";
String postStr1 = "business_id=790";
String postStr2 = "&rating=4";

HttpConnection httpConnection = (HttpConnection) Connector.open(url);
httpConnection.setRequestMethod(HttpConnection.POST);
httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

URLEncodedPostData encPostData = new URLEncodedPostData("UTF-8", false);
encPostData.append("business_id", String.valueOf(790));
encPostData.append("rating", String.valueOf(4));
byte[] postData = encPostData.toString().getBytes("UTF-8");

httpConnection.setRequestProperty("Content-Length", String.valueOf(postData.length));

OutputStream os = httpConnection.openOutputStream();
os.write(postData);
os.flush();

任何人有任何的想法是什么地方出错了?

Anyone have any ideas on what could be wrong?

推荐答案

有几件事情是怎么回事。首先,我的模拟器未连接到互联网正常。一旦得到了理顺,我删除了

A few things were going on. First, my simulator was not connecting to the internet properly. Once that got straightened out, I removed the

deviceside=true

这是我的网址,而现在它的伟大工程。谢谢大家!

from my url, and it now works great. Thanks all!

这篇关于HTTP POST与黑莓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆