












import com.baidubce.http.ApiExplorerClient; import com.baidubce.http.AppSigner; import com.baidubce.http.HttpMethodName; import com.baidubce.model.ApiExplorerRequest; import com.baidubce.model.ApiExplorerResponse; // 搜图 Java示例代码 public class RequestDemo { public static void main(String[] args) { String path = "https://jmrgzn2st.api.bdymkt.com/image/search"; ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.POST, path); request.setCredentials("您的 access key", "您的 secret key"); request.addHeaderParameter("Content-Type", "application/x-www-form-urlencoded"); ApiExplorerClient client = new ApiExplorerClient(new AppSigner()); try { ApiExplorerResponse response = client.sendRequest(request); // 返回结果格式为Json字符串 System.out.println(response.getResult()); } catch (Exception e) { e.printStackTrace(); } } }点击复制代码
{
"code": 200, //返回码,详见返回码说明
"msg": "成功", //返回码对应描述
"taskNo": "079281571242673018285611", //本次请求号
"data": [
{
"oriTitle": ". - 高清图片,堆糖,美图壁纸兴趣社区",//图片名
"width": 1000,//图片宽度
"hoverUrl": "https://img2.baidu.com/it/u=1451072963,3355621335&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667",//图片链接
"thumbnailUrl": "https://img2.baidu.com/it/u=1451072963,3355621335&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667",//图片缩略图链接
"height": 1000 //图片高度
}
]
}
{
"code": 400,
"msg": "关键字不能为空"
}
1,便捷关键词触发搜索结果;2,精准搜索返回海量图片信息。
