https://api.cenguigui.cn/api/qrcode/
GET
JSON
正常启用
以下参数为接口所需调用信息
| 参数 | 是否必填 | 类型 | 说明 | 示例 |
|---|---|---|---|---|
| 图片边距外框 | img | 是 | 默认1 可选1-10 | |
| 二维码复杂调整 | dt | 是 | 默认L 可选L,M,Q,H | |
| 要生成的文字或网址 | text | 是 | 文字或网址 |
https://api.cenguigui.cn/api/qrcode?img=1&dt=L&text=https://api.cenguigui.cn
1. css调用
background-image: url('https://api.cenguigui.cn/api/qrcode/?img=1&dt=L&text=填写需要调用的网址或文字');height: 330px;
2.img调用
< img src="https://api.cenguigui.cn/api/qrcode/?img=1&dt=L&text=填写需要调用的网址或文字" style="height: 330px;">
注意:css 可自行调节
height: 330px;
如改成 :height: 250px;
直接返回二维码图片
// JavaScript调用示例
fetch("https://api.cenguigui.cn/api/qrcode?img=1&dt=L&text=https://api.cenguigui.cn", {
method: "GET",
headers: {
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
# Python调用示例
import requests
url = "https://api.cenguigui.cn/api/qrcode?img=1&dt=L&text=https://api.cenguigui.cn"
response = requests.get(url)
print(response.json())
// Java调用示例
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class ApiExample {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_2)
.connectTimeout(Duration.ofSeconds(10))
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.cenguigui.cn/api/qrcode?img=1&dt=L&text=https://api.cenguigui.cn"))
.build();
client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.thenAccept(System.out::println)
.join();
}
}
<?php
// PHP调用示例
$url = "https://api.cenguigui.cn/api/qrcode?img=1&dt=L&text=https://api.cenguigui.cn";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
?>
// C#调用示例
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
var url = "https://api.cenguigui.cn/api/qrcode?img=1&dt=L&text=https://api.cenguigui.cn";
var response = await client.GetAsync(url);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
// 响应结果将显示在这里