稳定、快速、免费的 API 接口服务
共收录了
14 个接口
输入关键词搜索图片
接口地址: https://api.zdck8.com/Api/php/duitang
返回格式: JSON
请求方式: GET
请求示例: https://api.zdck8.com/Api/php/duitang?keyword=美女&
请求参数说明:
名称 | 必填 | 说明 |
---|---|---|
keyword | 否 | 美女 |
返回参数说明:
名称 | 类型 | 说明 |
---|---|---|
src | string | 图片链接 |
alt | string | 关键词 |
height | string | 图片高度 |
返回示例:
[ { "src": "https://c-ssl.dtstatic.com/uploads/blog/202402/01/AvS6gJANhw84lbm.thumb.400_0.jpeg", "alt": "美女", "height": "231" } ]
错误码格式说明:
名称 | 类型 | 说明 |
---|
PHP代码示例:
$get="https://api.zdck8.com/Api/php/duitang?keyword=美女&"; $result=file_get_contents($get); if($result) { //请求成功 echo $result; }else{ //请求失败 }
$url='https://api.zdck8.com/Api/php/duitang'; $data=array( 'keyword'=>'美女', ); $data=http_build_query($data); $option =array('http'=>array('method'=>'POST','content'=>$data)); $context=stream_context_create($option); $result=file_get_contents($url,false,$context); if($result) { //成功 echo $result; }else{ //失败 }
Java代码示例:
String httpurl = "https://api.zdck8.com/Api/php/duitang?keyword=美女&"; HttpURLConnection connection = null; InputStream is = null; BufferedReader br = null; String result = null; try { URL url = new URL(httpurl); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setConnectTimeout(15000); connection.setReadTimeout(60000); connection.connect(); if (connection.getResponseCode() == 200) { is = connection.getInputStream(); br = new BufferedReader(new InputStreamReader(is, "UTF-8")); StringBuffer sbf = new StringBuffer(); String temp = null; while ((temp = br.readLine()) != null) { sbf.append(temp); } result = sbf.toString(); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (null != br) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } if (null != is) { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } connection.disconnect(); } System.out.println(result);//返回内容
PrintWriter out = null; BufferedReader in = null; String result = ""; String param ="keyword=美女&"; String url ="https://api.zdck8.com/Api/php/duitang?"; try { URL realUrl = new URL(url); URLConnection conn = realUrl.openConnection(); conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("user-agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); conn.setDoOutput(true); conn.setDoInput(true); out = new PrintWriter(conn.getOutputStream()); out.print(param); out.flush(); in = new BufferedReader( new InputStreamReader(conn.getInputStream())); String line; while ((line = in.readLine()) != null) { result += line; } } catch (Exception e) { System.out.println("发送 POST 请求出现异常!"+e); e.printStackTrace(); } finally{ try{ if(out!=null){ out.close(); } if(in!=null){ in.close(); } } catch(IOException ex){ ex.printStackTrace(); } } System.out.println(result);//返回内容
JavaScript代码示例:
var url = "https://api.zdck8.com/Api/php/duitang?keyword=美女&" var xhrGet = new XMLHttpRequest(); xhrGet.open('GET',url, true); xhrGet.send(); xhrGet.onreadystatechange = function() { if (xhrGet.readyState == 4 && xhrGet.status == 200) { //成功 var result = xhrGet.responseText; console.log(result); } else { //失败 } }
var url ="https://api.zdck8.com/Api/php/duitang"; var data = "keyword=美女&"; var xhrPost = new XMLHttpRequest(); xhrPost.open('POST', url, true); xhrPost.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhrPost.send(data); xhrPost.onreadystatechange = function() { if (xhrPost.readyState == 4 && xhrPost.status == 200) { //成功 var result = xhrPost.responseText; console.log(result); } else { //失败 } }