| 接口地址:https://v2.xxapi.cn/api/webp |
|---|
| 返回格式:json |
| 请求方式:get/post |
| 请求示例:https://v2.xxapi.cn/api/webp?url=https://xxapi.cn/logo.png |
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| url | string | 必填 | 传入要转换为webp的图片URL |
| 名称 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,200 表示成功 |
| msg | string | 状态说明 |
| data | string | 转换后的 webp 图片 URL |
| request_id | string | 请求ID |
{
"code": 200,
"msg": "数据请求成功",
"data": "https://cdn.xxhzm.cn/v2api/cache/tmp/dd56587890af3fb8e2616a1e86d4c6dbaef47980.webp",
"request_id": "8f4eee2f9560f30d0ad93df9"
}| 错误码 | 说明 |
|---|---|
| 200 | 数据请求成功 |
<?php
/**
* Created by PhpStorm.
* User: FZS
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'https://v2.xxapi.cn/api/webp?url=https://xxapi.cn/logo.png';
}
/**
* 获取结果
* @return array
*/
public function getResult()
{
return file_get_contents($this->apiUrl);
}
}package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
const (
APIURL = "https://v2.xxapi.cn/api/webp?url=https://xxapi.cn/logo.png"
)
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))
}