1、新建在网站根目录下创建一个文件夹

2、进入文件夹里创建两个文件 -- index.php img.txt

3、进入 index.php 输入以下内容

<?php
//此php和保存链接的txt文件放在同一目录下
$filename = "img.txt";  /*保存链接的txt文件名*/
if(!file_exists($filename)){
    die('文件不存在');
}
//从文本获取链接
$pics = [];
$fs = fopen($filename, "r");
while(!feof($fs)){
    $line=trim(fgets($fs));
    if($line!=''){
        array_push($pics, $line);
    }
}
//从数组随机获取链接
$pic = $pics[array_rand($pics)];
//返回指定格式
$type=$_GET['type'];
switch($type){
//JSON返回
case 'json':
    header('Content-type:text/json');
    die(json_encode(['pic'=>$pic]));
default:
    die(header("Location: $pic"));
}
?>

4、进入 img.txt 输入你要的图片链接

https://api.cwlm.xyz/1.png
https://api.cwlm.xyz/2.png
https://api.cwlm.xyz/3.png
https://api.cwlm.xyz/4.png
https://api.cwlm.xyz/5.png
https://api.cwlm.xyz/6.png
https://api.cwlm.xyz/7.png
https://api.cwlm.xyz/8.png
https://api.cwlm.xyz/9.png
https://api.cwlm.xyz/10.png

最后访问你的域名即可调用