朋友圈文案接口
parent
3a354c94ec
commit
6ce73c2dc8
|
@ -1,23 +0,0 @@
|
||||||
package com.muyu.cloud.background.domin.apiresp;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.cloud.background.domin.apiresp
|
|
||||||
* @Project:cloud-background
|
|
||||||
* @name:IdCardResp
|
|
||||||
* @Date:2024/9/4 14:33
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class IdCardResp {
|
|
||||||
private String realname;
|
|
||||||
private String idcard;
|
|
||||||
private String orderid;
|
|
||||||
private Integer res;
|
|
||||||
}
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.muyu.cloud.background.api;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:weiran
|
||||||
|
* @Package:com.muyu.cloud.background.api
|
||||||
|
* @Project:cloud-background
|
||||||
|
* @name:JavaGet
|
||||||
|
* @Date:2024/8/29 20:24
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 朋友圈文案
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class Friendcircle {
|
||||||
|
|
||||||
|
public static Result fetchQuotes() throws Exception {
|
||||||
|
String apiKey = "d280c72b48ab26535b186d71f19f185d"; // 您的API密钥
|
||||||
|
String apiUrl = "http://apis.juhe.cn/fapigx/pyqwenan/query?key=" + apiKey;
|
||||||
|
URL url = new URL(apiUrl);
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
conn.setRequestProperty("Accept", "application/json");
|
||||||
|
|
||||||
|
if (conn.getResponseCode() != 200) {
|
||||||
|
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||||
|
StringBuilder response = new StringBuilder();
|
||||||
|
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null) {
|
||||||
|
response.append(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.disconnect();
|
||||||
|
|
||||||
|
// 假设parseQuotesFromJson是解析JSON并提取所需数据的方法
|
||||||
|
// 这里需要您自己实现这个方法
|
||||||
|
String parsedData = parseQuotesFromJson(response.toString());
|
||||||
|
|
||||||
|
// 返回包含解析后数据的Result对象
|
||||||
|
return Result.success(parsedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 这是一个假想的方法,用于解析JSON
|
||||||
|
private static String parseQuotesFromJson(String json) {
|
||||||
|
// 这里应该使用JSON解析库(如Jackson或Gson)来解析json字符串
|
||||||
|
// 并提取出您需要的数据
|
||||||
|
// 由于这是一个示例,我们只是简单地返回整个json字符串(这在实际中是没有意义的)
|
||||||
|
return json; // 注意:这里应该返回解析后的数据,而不是原始json
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.cloud.background.controller;
|
package com.muyu.cloud.background.controller;
|
||||||
|
|
||||||
import com.muyu.cloud.background.api.DateCalendar;
|
import com.muyu.cloud.background.api.DateCalendar;
|
||||||
|
import com.muyu.cloud.background.api.Friendcircle;
|
||||||
import com.muyu.cloud.background.api.MobileLocation;
|
import com.muyu.cloud.background.api.MobileLocation;
|
||||||
import com.muyu.cloud.background.api.News;
|
import com.muyu.cloud.background.api.News;
|
||||||
import com.muyu.cloud.background.domin.api.IdCard;
|
import com.muyu.cloud.background.domin.api.IdCard;
|
||||||
|
@ -85,6 +86,18 @@ public class ApiUserController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 朋友圈文案
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@PostMapping("/friendcircle")
|
||||||
|
@Operation(summary = "朋友圈文案",description = "朋友圈文案")
|
||||||
|
public Result JavaGet() throws Exception {
|
||||||
|
Result result = Friendcircle.fetchQuotes();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue