接口地址:https://cn.apihz.cn/api/zici/baijiaxing.php |
---|
返回格式:json |
请求方式:get/post |
请求示例:https://cn.apihz.cn/api/zici/baijiaxing.php?id=10006620&key=key&xing=李&type=0 |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
id | int | 必填 | 对应平台开发者ID |
key | string | 必填 | 对应平台开发者密钥 扫码关注公众号 |
string | 选填 | 姓氏,如不传则随机返回一个姓氏。 |
名称 | 类型 | 说明 |
---|---|---|
surname | string | 姓氏 |
initial | string | 姓氏首字母。 |
num | string | 姓氏字数 |
img | string | 姓氏图腾或相关图片 |
{
"code": 200,
"surname": "李",
"initial": "L",
"num": "1",
"img": "https://rescdn.apihz.cn/resimg/baijiaxing/uploads/20240211/d5ee276ec3f1f903a1f6df4831aca6b9.jpg",
"content": "一、来源有三 1、出自嬴姓,为颛顼帝高阳氏之后裔..."
}
错误码 | 说明 |
---|---|
- | - |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2025/7/31 21:11
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'https://cn.apihz.cn/api/zici/baijiaxing.php?id=10006620&key=key&xing=李&type=0';
}
/**
* 获取结果
* @return array
*/
public function getResult()
{
return file_get_contents($this->apiUrl);
}
}
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
const (
APIURL = "https://cn.apihz.cn/api/zici/baijiaxing.php?id=10006620&key=key&xing=李&type=0"
)
func main() {
queryUrl := fmt.Sprintf("%s",APIURL)
resp, err := http.Get(queryUrl)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}