1
我想在我的黑莓应用程序中设置一个http文章。我已经在我的相应Android应用程序中成功实现了这个功能,所以我知道它工作的服务器找到了。我尝试了几个不同的东西,而且我没有真正得到错误,它只是在服务器上的信息没有得到更新。我看过这个帖子: Http POST in 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();
任何人有什么想法可能是错的?
如果您调用httpConnection.getResponseMessage(),会得到什么信息? – Jonathan
你可能想看看这个:http://stackoverflow.com/questions/7455891/j2me-app-not-sending-post-requests –
我得到:暂时移动......这是什么意思? – coder