项目接口!而不是Java接口,我想要接口的详细解释,最近做项目需要调用别的公司提供的接口
像webservice这样的吗?
调用别人公司提供的接口,我五月份做过一个类似的订单同步接口,用户下预约单,然后去柜台购买手机和手机号以及选择套餐,需要用到okhttp。部分代码如下:
OkHttpUtil.Content responseContent;
Map map = new HashMap<>();
String pro = Preference.current().getString("", null);// 读取配置文件
String code = ConstantUtil.CODE_ERROR;
String msg = ConstantUtil.MSG_ERROR;
...
SynorderRequest request = new SynorderRequest();
request.setAppid(Preference.current().getString("", null));
request.setToken(Preference.current().getString("", null));
responseContent = OkHttpUtil.post(Preference.current().getString("yzcx_ddtb_zsurl", null),
MyMediaType.JSON, ConvertUtil.toJSON(request));
....
if (!responseContent.isEmpty()) {
JSONObject jsondata = ConvertUtil.toJsonObject(new String(responseContent.getData(),"utf8"));
code = !jsondata.isNull("code") ? jsondata.getString("code") : "";
msg = !jsondata.isNull("msg") ? jsondata.getString("msg") : "";
...
一般调用别人的接口,接口提供方是回给接口文档的,按照文档来调用,很简单。