地址:https://open.cnipr.com/cnipr-api/rs/api/trademark/tms2/{client_id}?openid={openid}&access_token={access_token}
HTTP POST
client_id,openid,access_token,dbs,exp,filter,from,size,order,displayCols,imgContent,imgMinScore 参数含义见外观附录-检索分析参数
{ "exp":"int_cls=27", "dbs":"CN", "order":"+app_date", "from":"0", "size":"10", "displayCols":"", "imgMinScore":90, "imgContent":"Base64" }
public class SearchClientTest { String client_id = ""; String openid = ""; String access_token = ""; /** * 表达式+名称检索 */ public void tms2Test() throws Exception { String url = String.format("https://open.cnipr.com/cnipr-api/rs/api/trademark/tms2/%s?openid=%s&access_token=%s", client_id, openid, access_token); String json = "{ \n" + " \"exp\":\"int_cls=27\",\n" + " \"dbs\":\"CN\",\n" + " \"order\":\"+app_date\",\n" + " \"from\":\"0\",\n" + " \"size\":\"10\",\n" + " \"displayCols\":\"\",\n" + " \"imgMinScore\":90,\n" + " \"imgContent\":\"Replace with Base64 Data\"\n" + "}"; String result = POST(url, json); System.out.println(result); } public String POST(String url, String json) throws Exception { HttpClient httpClient = HttpClients.createDefault(); HttpPost httppost = new HttpPost(url); httppost.setHeader("ContentType", "application/json"); StringEntity entity = new StringEntity(json, "UTF-8"); entity.setContentType("application/json"); httppost.setEntity(entity); HttpResponse response = httpClient.execute(httppost); HttpEntity result = response.getEntity(); String ss = EntityUtils.toString(result, "UTF-8"); EntityUtils.consume(entity); return ss; } }
/** * @Description: 根据图片地址转换为base64编码字符串 */ public static String convertImageToBase64String(String imgFile) { InputStream inputStream = null; byte[] data = null; try { inputStream = new FileInputStream(imgFile); data = new byte[inputStream.available()]; inputStream.read(data); inputStream.close(); } catch (IOException e) { e.printStackTrace(); } return Base64.getEncoder().encodeToString(data); }
属性名称 | 属性说明 | 属性类型 |
---|---|---|
status | 状态码,0代表成功,其它值含义见附录 | long |
message | 响应的信息描述 | String |
total | 命中总数 | long |
from | 分段检索,开始值 | int |
to | 分段检索,结束值 | int |
records | 检索结果 | List<商标详细信息> -- 数据详细 |