Full use of https!

https://api.hotaru.icu/api/ipcard?apikey=b699b2d60915d83f3723272855240c4c
星座运势查询API
当前接口累计调用290次 今日调用0次
查星座运势的东西,真的有人信吗? Time:2023-01-17 22:41:00

接口地址: https://api.hotaru.icu/api/starluck

返回类型: application/json

请求方式: GET/POST

请求示例: https://api.hotaru.icu/api/starluck?msg=天蝎座

请求参数说明:

名称 必填 类型 说明
msgstring星座名,如:天蝎座

返回参数说明:

名称 类型 说明
namestring星座名字
infoarray星座信息
indexarray星座运势

返回示例:

{
    "code": 500,
    "message": "success",
    "data": {
        "name": "天蝎座",
        "info": [
            "健康指数:80%",
            "商谈指数:79%",
            "幸运颜色:姜黄色",
            "幸运数字:2",
            "速配星座:天蝎座",
            "短评:被卷入信息流中"
        ],
        "index": [
            "综合运势:整体运势稍有起伏,意志力不坚定,容易受外界的干扰。接收的信息很多,却未必对自己都有用,反而容易在其中随波逐流。生活方面平平淡淡,有时间可以做一些积极向上的安排,寻找充实感。",
            "爱情运势:单身的受大环境影响,或有婚恋观的变化。恋爱中的或有生闷气的情况,要保持沟通。",
            "事业学业:接收第一手信息有利于走在时间前面,但不能反过来被牵着鼻子走,注意筛选分辨。",
            "财富运势:以正财和微薄小财的进账维持日常花销,建议养成记账的习惯,有目标地存一笔钱。",
            "健康运势:宅在一个环境中容易出现负面情绪,建议出门走走,散散心,或是转移注意力。"
        ]
    }
}

状态码说明:

名称 说明

调用示例:

PHP:
<?php
$result = file_get_contents("https://api.hotaru.icu/api/starluck?msg=天蝎座");
var_dump($result);
?>

JavaScript:
const url = "https://api.hotaru.icu/api/starluck?msg=天蝎座";
fetch(url)
  .then(res => res.json)
  .(res => {
    console.log(res);
  });

Python:
import requests

url="https://api.hotaru.icu/api/starluck?msg=天蝎座"
payload={}
r = requests.get(url,params=payload)
print(r);

lua:
local httputil = HttpUtil()
local url = "https://api.hotaru.icu/api/starluck?msg=天蝎座"
local resStr
local res,code = httputil.httpPost(url,str)
    if code ~= 200 then
        ngx.log(ngx.WARN,"code:"..code)
            return resStr
    end
resStr = res

C/C++:
#include <iostream>  
#include <string>  
#include "curl/curl.h"  
using namespace std;  

#pragma comment(lib, "ws2_32.lib")  
#pragma comment(lib, "wldap32.lib")  
#pragma comment(lib, "libcurl.lib")  

size_t req_reply(void *ptr, size_t size, size_t nmemb, void *stream)  
{  
    cout << "----->reply" << endl;  
    string *str = (string*)stream;  
    cout << *str << endl;  
    (*str).append((char*)ptr, size*nmemb);  
    return size * nmemb;  
}  

CURLcode curl_get_req(const std::string &url, std::string &response)  
{  
    CURL *curl = curl_easy_init();  
    CURLcode res;  
    if (curl)  
    {  
        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);  
        curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);  
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, req_reply);  
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&response);  
        curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);  
        curl_easy_setopt(curl, CURLOPT_HEADER, 1);  
        curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 3);
        curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3);  
        res = curl_easy_perform(curl);  
    }  
    curl_easy_cleanup(curl);  
    return res;  
}  


int main()  
{  
    curl_global_init(CURL_GLOBAL_ALL);  

    string getUrlStr = "https://api.hotaru.icu/api/starluck?msg=天蝎座";  
    string getResponseStr;  
    auto res = curl_get_req(getUrlStr, getResponseStr);  
    if (res != CURLE_OK)  
        cerr << "curl_easy_perform() failed: " + string(curl_easy_strerror(res)) << endl;  
    else  
        cout << getResponseStr << endl;  

    curl_global_cleanup();  
    system("pause");  
    return 0;  
}  

Java:
package com.jl.chromeTest;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;

public class Test {

    @org.junit.Test
    public void test() throws Exception{
        String result = get("https://api.hotaru.icu/api/starluck?msg=天蝎座");
        System.out.println("result====="+result);
    }
    
    public  String get(String url) throws Exception {
        String content = null;
        URLConnection urlConnection = new URL(url).openConnection();
        HttpURLConnection connection = (HttpURLConnection) urlConnection;
        connection.setRequestMethod("GET");
        connection.connect();
        int responseCode = connection.getResponseCode();
        if (responseCode == HttpURLConnection.HTTP_OK) {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader
                (connection.getInputStream(), StandardCharsets.UTF_8));
            StringBuilder bs = new StringBuilder();
            String l;
            while ((l = bufferedReader.readLine()) != null) {
                bs.append(l).append("\n");
            }
            content = bs.toString();
        }
        return content;
    }
}

CS:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.hotaru.icu/api/starluck?msg=天蝎座");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
String result = new StreamReader(response.GetResponseStream()).ReadToEnd();

Golang:
func httpGet() {
    resp, err :=   http.Get("https://api.hotaru.icu/api/starluck?msg=天蝎座")
    if err != nil {
    }

    defer resp.Body.Close()
    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
    }

    fmt.Println(string(body))
}


EPL:
.版本 2

.局部变量 待返回, 文本型

待返回 = 编码_utf8到gb2312 (到文本 (网页_访问_对象 (“https://api.hotaru.icu/api/starluck?msg=天蝎座”)))