打包com.cn.baidu;
導入java.io.BufferedReader;
導入java.io.IOException;
導入java.io.InputStream;
導入java.io.InputStreamReader; 導入java.util.List;
導入org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
導入org.apache.commons.httpclient.Header; Clorg.apache.commons.httpcliclient.HttCl. commons.httpclient.HttpException;
導入org.apache.commons.httpclient.HttpStatus;
導入org.apache.commons.httpclient.methods.GetMethod;
org.apache.commons.httpclient.methods.GetMethod;
.假期
{
/**
* @param urlAll :請求介面
* @param httpArg :參數
* @return 回傳結果
*/
public static String request(String httpArg)
{
String httpUrl = "http://www.easybots.cn/api/holiday.php";
// = "http://apis.baidu.com/xiaogg/holiday/holiday";
HttpClient httpClient = new HttpClient();
GetMethod 方法= new GetMethod(httpUrl+"?"+httpArg);
字串回應= "" ;
嘗試
{
//需要加入標題資料
List
Header header = new Header();
header.setName("apikey"); setValue("7bd4e99adcc28e337cea79191fef87fc");
headers.add(header);
httpClient.getHostConfiguration().getParams().setParameter("httpClient.getHostConfiguration().getParams().setParameter("httpClient.m." ams. RETRY_HANDLER, new DefaultHttpMethodRetryHandler());
int statusCode = httpClient.executeMethod(method);
if (statusCode == HttpStatus.SC_OK)
{ StreamStreamStreamStream 獲取到的資訊/發送資訊).
BufferedReader br = new BufferedReader(new InputStreamReader(resStream));
StringBuffer resBuffer = new StringBuffer();
String resTemp = "";
while ((resTemp = br.readLine() ! append(resTemp);
}
response = resBuffer.toString();
}
}
catch (HttpException e)
{
e.printStack (HttpException e)
{
e.printStack (HttpException e)
{
e.printStack (Htt); e.printStackTrace( );
}
終於
{
method.releaseConnection();
}
回傳回應;
}
public static v.結果為1,假日回覆結果為2
String httpArg = "d="+"2016 -11-20".replaceAll("-", "");
String jsonResult = request(httpArg);
System.out. println(jsonResult);
}
}

關於JWT和Session的困惑與解答許多初學者在學習JWT和Session時,常常會對其本質和適用場景感到困惑。本文將圍繞J...

WindowsServer2019防火牆與WebSocket通信問題詳解在使用SpringBoot開發的Jar程序部署於WindowsServer2019...

Java單線程下的指令重排序與輸出順序在Java編程中,指令重排序是一個常見的優化技術,用於提高程序的執行效�...

IntelliJIDEA如何識別SpringBoot項目的端口號?在使用IntelliJIDEAUltimate版本時,啟動Spring...

通過OAuth2.0的access_token如何精細控制接口訪問權限?在現代應用開發中,OAuth2.0...

深入剖析RuoYi框架的Bean依賴注入機制:無需顯式實現類RuoYi框架是一個流行的Java前後端分離框架,其簡潔的代碼...


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

Dreamweaver CS6
視覺化網頁開發工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3漢化版
中文版,非常好用