汉服新闻
ALAPI 官方文档
获取有关汉服新闻数据
基本说明:
接口地址:https://v1.alapi.cn/api/new/hanfu
返回格式:json
请求方式:get/post
请求示例:https://v1.alapi.cn/api/new/hanfu?num=10
请求参数说明:
名称 类型 必填 说明
num int 选填 请求条数
page int 选填 页码
rand int 选填 是否随机获取,默认1
word string 选填 搜索关键字,默认无
返回参数说明:
名称 类型 说明
- - -
JSON返回示例:
{
	"code": 200,
	"msg": "success",
	"data": [{
			"ctime": "2020-03-08 14:26",
			"title": "超级漂亮的汉服发型分享!!手残党看过来",
			"source": "新浪汉服",
			"picUrl": "http://n.sinaimg.cn/front20200308ac/136/w576h360/20200308/e140-iqrhckm1619071.jpg",
			"url": "https://k.sina.com.cn/article_6090644865_m16b07dd810330140r2.html?from=fashion"
		},
		{
			"ctime": "2020-03-08 12:28",
			"title": "基础的汉服发型教程!非常日常百搭",
			"source": "新浪汉服",
			"picUrl": "http://n.sinaimg.cn/front20200308ac/136/w576h360/20200308/057d-iqrhckm1158631.jpg",
			"url": "https://k.sina.com.cn/article_6090644865_m16b07dd810330140n9.html?from=fashion"
		},
		{
			"ctime": "2020-03-08 13:27",
			"title": "简单易学,只需要一个假发包的汉服发型分享~~",
			"source": "新浪汉服",
			"picUrl": "http://n.sinaimg.cn/front20200308ac/136/w576h360/20200308/7224-iqrhckm1374555.jpg",
			"url": "https://k.sina.com.cn/article_6090644865_m16b07dd810330140ox.html?from=fashion"
		},
		{
			"ctime": "2020-03-08 02:39",
			"title": "DIY手工编绳教程:能快速编织好的蝴蝶流苏挂饰,搭汉服刚刚好",
			"source": "新浪汉服",
			"picUrl": "http://n.sinaimg.cn/sinakd20200308ac/794/w480h314/20200308/a65b-iqmtvwv9042294.jpg",
			"url": "https://k.sina.com.cn/article_6441009173_17fea001500100pl8d.html?from=fashion"
		},
		{
			"ctime": "2020-03-07 21:02",
			"title": "中国穿汉服才能进入的园林,打招呼也用古语,不然就拒绝进入",
			"source": "新浪汉服",
			"picUrl": "http://n.sinaimg.cn/sinakd10121/124/w578h346/20200307/091d-iqmtvwv8350837.jpg",
			"url": "https://k.sina.com.cn/article_7203240540_1ad58ba5c00100q7wi.html?from=travel&subch=insurance"
		},
		{
			"ctime": "2020-03-07 21:39",
			"title": "绝版汉服鲛人泪拆开快递的那一刻整个人都特别兴奋",
			"source": "新浪汉服",
			"picUrl": "http://n.sinaimg.cn/sinakd10121/400/w1280h720/20200307/f6b3-iqmtvwv8472498.jpg",
			"url": "https://k.sina.com.cn/article_6793628450_m194ee8b2200100njgw.html?from=ent&subch=variety"
		},
		{
			"ctime": "2020-03-07 21:42",
			"title": "22岁漂亮女孩求职一身汉服惊艳亮相让企业家直夸好看",
			"source": "新浪汉服",
			"picUrl": "http://n.sinaimg.cn/sinakd10121/400/w1280h720/20200307/fcd8-iqmtvwv8425514.jpg",
			"url": "https://k.sina.com.cn/article_6910673993_m19be8844900100xakp.html?from=ent&subch=variety"
		},
		{
			"ctime": "2020-03-07 23:44",
			"title": "次惑小仙女:拍汉服吃火鸡面+毛豆,居然被表白了",
			"source": "新浪汉服",
			"picUrl": "http://n.sinaimg.cn/front20200307ac/320/w480h640/20200307/29ff-iqmtvwv8786187.jpg",
			"url": "https://k.sina.com.cn/article_2932882881_maed03dc103300w6oc.html?from=food"
		},
		{
			"ctime": "2020-03-08 00:05",
			"title": "美少女cosplay:复古风汉服写真(侵删)",
			"source": "新浪汉服",
			"picUrl": "http://n.sinaimg.cn/sinakd10100/704/w1440h864/20200308/b24c-iqmtvwv8817930.jpg",
			"url": "https://k.sina.com.cn/article_7062056909_p1a4ee6fcd00100qq5d.html?from=animation"
		},
		{
			"ctime": "2020-03-06 08:51",
			"title": "汉服古风:十二楼中尽晓妆,望仙楼上望君王",
			"source": "新浪汉服",
			"picUrl": "http://n.sinaimg.cn/sinakd10108/634/w999h1235/20200306/857d-iqmtvwv1129637.jpg",
			"url": "https://k.sina.com.cn/article_6995117639_p1a0f1064700100pruo.html?from=photo"
		}
	],
	"Author": {
		"name": "Alone88",
		"desc": "由Alone88提供的免费API 服务,官方文档:www.alapi.cn"
	}
}
服务级错误码参照
错误码 说明
500 处理异常
完整教学代码示例
<?php

/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2020/02/01 00:16
 */
class freeApi
{
    private $apiUrl;

    public function __construct()
    {
        $this->apiUrl = 'https://v1.alapi.cn/api/new/hanfu';
    }

    /**
     * 获取结果
     * @return array
     */
    public function getResult()
    {
        return file_get_contents($this->apiUrl);
    }
}
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

const (
	APIURL   = "https://v1.alapi.cn/api/new/hanfu"
)

func main() {
	queryUrl := fmt.Sprintf("%s?num=1",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))
}