360搜图
通过关键词在360搜索图片

接口地址: https://api.zdck8.com/Api/php/360image

返回格式: JSON

请求方式: GET

请求示例: https://api.zdck8.com/Api/php/360image?keyword=美女&

请求参数说明:

名称 必填 说明
keyword 美女

返回参数说明:

名称 类型 说明
status string success-成功/error-错误
imageUrl string 图片链接

返回示例:

{
  "status": "success",
  "imageUrl": "https://up.enterdesk.com/edpic/7b/fa/39/7bfa3943dbd83c4188def225985d3c2e.jpg"
}

错误码格式说明:

名称 类型 说明
1001 String 没有关键词
1002 String 图片没有找到

PHP代码示例:


$get="https://api.zdck8.com/Api/php/360image?keyword=美女&";
$result=file_get_contents($get);
if($result)
{
//请求成功
echo $result;
}else{
//请求失败
}

$url='https://api.zdck8.com/Api/php/360image';
$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/360image?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/360image?";
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/360image?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/360image";
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 {
//失败
}
}