黑莓的http post

发布于 2024-12-06 01:28:13 字数 1114 浏览 0 评论 0原文

我正在尝试在我的 Blackberry 应用程序中设置 http 帖子。我已经在相应的 Android 应用程序中成功实现了此功能,因此我知道它正在查找的服务器。我尝试了几种不同的方法,但我并没有真正收到错误,只是服务器上的信息没有更新。我看过这个帖子: BlackBerry 中的 Http POST 以及其他几个。我发现它们很有帮助,但它们并没有最终解决我的问题。同样,我没有收到错误,但服务器没有更新。这是我当前使用的代码:

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();

有人对可能出现的问题有任何想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

≈。彩虹 2024-12-13 01:28:13

发生了一些事情。首先,我的模拟器无法正确连接到互联网。一旦解决了这个问题,我就

deviceside=true

从我的网址中删除了 ,现在效果很好。谢谢大家!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文