小米壁纸

获取小米壁纸

接口地址
https://wmkxz.cn/api/xmbz
返回格式
JUMP/TEXT/IMAGE
请求方式
GET/POST
请求示例
https://wmkxz.cn/api/xmbz?form=风景
重要提示: 所有接口需携带秘钥,以免更新导致请求失败!

请求参数说明

名称 必填 类型 说明
form string 风景,星空,爱情,插画,科技,创意,汽车,美食,潮流
type string 返回格式,默认json,可选text/image/jump

返回参数说明

名称 类型 说明
code string 状态码
text string 是否成功
img string 图片链接
width int 高度
height int 宽度

返回示例

JSON
{
    "code": 1,
    "text": "获取成功",
    "img": "https://ts.market.mi-img.com/thumbnail/webp/w480q100/ThemeMarket/03c1af62f47294d8da8d374deae3a84b0f13e3ac8",
    "width": 480,
    "height": 853
}

在线调试工具

调试工具支持的请求类型有:GETPOSTPUTHEADTRACEDELETECONNECTOPTIONS

请求参数设置:

返回结果

{ "code": 1, "text": "获取成功", "img": "https://ts.market.mi-img.com/thumbnail/webp/w480q100/ThemeMarket/03c1af62f47294d8da8d374deae3a84b0f13e3ac8", "width": 480, "height": 853 }

错误码格式说明

名称 类型 说明
-2 string 壁纸类型不存在
-1 string 请输入壁纸类型

代码示例

多种语言
<?php

$apiUrl = "https://wmkxz.cn/api/xmbz?form=风景&apiKey=密钥";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
}

curl_close($ch);
$responseData = json_decode($response, true);

if ($responseData['code'] == 1) {
echo "图片链接: " . $responseData['img'];
} else {
echo "API调用失败: " . $responseData['text'];
}

?>