7
我们使用Phil Sturgeons cool Restful API framework for codeigniter构建了我们的API,该工具已准备就绪,并且可用作我们移动应用实施的一部分。Restful API codeigniter - JAVA问题
我们当使用API在Java中
httpConnection = (HttpConnection) Connector.open(url, Connector.READ, true);
// Set content type by given parameter......
httpConnection.setRequestProperty("Accept", contentType);
httpConnection.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/FCLDC-1.0");
httpConnection.setRequestProperty("Content-Type", contentType);
httpConnection.setRequestProperty("TK-API-KEY", UrlFactory.TK_API_KEY);
// httpConnection.setRequestProperty("Model",
// StyleUtil.getDeviceModel());
if (httpConnection.getResponseCode() == 302)
{
String redirectUrl = httpConnection.getHeaderField("Location");
httpConnection = (HttpConnection) Connector.open(redirectUrl, Connector.READ_WRITE, true);
}
if (httpConnection.getResponseCode() == HttpConnection.HTTP_OK)
{
io = httpConnection.openInputStream();
int ch;
while ((ch = io.read()) != -1)
{
bo.write(ch);
}
}
httpConnection.getResponseCode()
无法获取状态代码,并返回一个畸形的异常有一个问题。我们的API服务器是NGINX。
你可以发布它返回的内容吗? – Broncha
你有没有得到这个工作? – seangates
如果[CI](http://codeigniter.com)没有必要,您可以给[jabsorb](http://code.google.com/p/jabsorb/)一个机会。 – quantme