1. 创建站点

在宝塔面板的网站中添加站点作为API地址,将网站开启PHP,并申请一个SSL认证并打开强制https

2. 创建图片链接

打开这个站点的目录,创建一个img.txt和一个index.php

在PicList的管理中中全部选中并复制图片url,将链接粘贴到img.txt中

index.php写入如下内容

<?php
//存有美图链接的文件名img.txt
$filename = "img.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)];
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Expires: 0');
header("Location: $pic");
die();
?>

参考文章

创建自己的随机图片api