接口详情

—

基本信息

接口地址—
请求方式—
返回参数格式—
请求参数—
价格—

请求示例

—

授权认证

认证方式—
认证示例—

示例代码

package com.example.demo.http;

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;

public class HttpDemo {

    public static void main(String[] args) {
        String secretkey = "您的secretkey";
        //请求示例地址
        String url = "请求的接口地址";

        HttpGet httpGet = new HttpGet(url);
        httpGet.setHeader("secretkey", secretkey);

        CloseableHttpClient httpClient = HttpClients.createDefault();
        CloseableHttpResponse httpResponse;
        String result = null;
        try {
            httpResponse = httpClient.execute(httpGet);
            if (httpResponse.getStatusLine().getStatusCode() == 200) {
                result = EntityUtils.toString(httpResponse.getEntity(), "utf-8");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                httpClient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        System.out.println(result);
    }
}
                

示例代码为登录用户专享

登录后可查看各语言接入示例