以下是使用 PHP 编写的生成二维码的接口文件:

<?php

// 检查是否传递了 url 参数
if(!isset($_GET['url'])) {
    die('参数错误');
}

// 获取 url 参数值
$url = $_GET['url'];

// 设置二维码尺寸
$size = 6;

// 生成二维码图片
$qrCode = 'https://api.qrserver.com/v1/create-qr-code/?size=' . $size . 'x' . $size . '&data=' . urlencode($url);

// 输出图片
header('Content-Type: image/png');
readfile($qrCode);

?>

使用方法:将以上代码保存为一个.php文件,放置在你的服务器上。然后通过访问接口文件路径?url=你的网址即可生成对应网址的二维码。例如,如果你的接口文件路径是http://example.com/qrcode.php,你想生成的网址是http://example.com/target-page,你可以通过访问http://example.com/qrcode.php?url=http://example.com/target-page来生成对应的二维码。

PHP 生成二维码接口文件 - 简单易用

原文地址: https://www.cveoy.top/t/topic/pdNF 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录