{ "code": 200, "msg": "success", "data": { "lunar_year": "2022", "lunar_month": "01", "lunar_day": "22", "lunar_hour": "13", "lunar_year_chinese": "二零二二", "lunar_month_chinese": "正月", "lunar_day_chinese": "廿二", "lunar_hour_chinese": "未时", "ganzhi_year": "壬寅", "ganzhi_month": "壬寅", "ganzhi_day": "丙午", "ganzhi_hour": "乙未", "wuxing_year": "水木", "wuxing_month": "水木", "wuxing_day": "火火", "wuxing_hour": "木土", "color_year": "黑", "color_month": "黑", "color_day": "红", "color_hour": "青", "animal": "虎", "term": null, "is_leap": false, "gregorian_year": "2022", "gregorian_month": "02", "gregorian_day": "22", "gregorian_hour": "13", "week_no": 2, "week_name": "星期二", "is_today": true, "constellation": "双鱼", "is_same_year": true }, "time": 1645509579, "log_id": 354626638298177536 }
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://v2.alapi.cn/api/lunar", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "token=用户中心获取token&date=2021-04-29-23&unix_time=1619710205", CURLOPT_HTTPHEADER => array( "Content-Type: application/x-www-form-urlencoded", ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://v2.alapi.cn/api/lunar" payload := strings.NewReader("token=用户中心获取token&date=2021-04-29-23&unix_time=1619710205") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/x-www-form-urlencoded") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) }