PHP随机风景图片接口源码
[alert class="success"]#(滑稽)再也不用bing每日图片了,用大米API自己也能换风景图[/alert]
所有图片格式均为.JPG,支持JSON输出。
<?php
/**
*2019-12-16
*/
header('Content-type:text/json;charset=utf-8;');
header('Access-Control-Allow-Origin:*');
$filepath='./viewtext.txt';
$urlramdm = file($filepath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$urlcount=rand(0,count($urlramdm)-1);
$size_arr = array('large', 'mw1024', 'mw690', 'bmiddle', 'small', 'thumb180', 'thumbnail', 'square');
$size = !empty($_GET['size']) ? $_GET['size'] : 'large' ;
$server = rand(1,4);
if(!in_array($size, $size_arr)){
$size = 'large';
}
$url = 'https://pan.qqsuu.cn/view/'.$urlramdm[$urlcount].'.jpg';
//解析结果
$result=array("code"=>"200","viewurl"=>"".$url);
//Type Choose参数代码
$type=$_GET['type'];
switch ($type)
{
//格式解析
case 'json':
$path = "$url";
$pathinfo = pathinfo($path);
$imageInfo = getimagesize($url);
$result['width']="$imageInfo[0]";
$result['height']="$imageInfo[1]";
$result['size']="$pathinfo[extension]";
header('Content-type:text/json');
echo json_encode($result);
break;
//格式解析 小韩博客提供技术支持
case 'img':
$img = file_get_contents($url,true);
header("Content-Type: image/jpeg;");
echo $img;
break;
//IMG
default:
header("Location:".$result['viewurl']);
break;
}
?>
[alert class="warning"]将上述代码保存为xx.php,上传至服务器;创建一个xx.txt文档 在里面进行数字排序,你需要多少张随机图片就写多少数字就好了,一行一个。最大上限:1100张!:[/alert]
1 2 3 4 5 6 7 8 9 .......等等
|| 版权声明
作者:大米
链接:https://blog.qqsuu.cn/1764.html
声明:如无特别声明本文即为原创文章仅代表个人观点,版权归《大米博客》所有,欢迎转载,转载请保留原文链接。
作者:大米
链接:https://blog.qqsuu.cn/1764.html
声明:如无特别声明本文即为原创文章仅代表个人观点,版权归《大米博客》所有,欢迎转载,转载请保留原文链接。
THE END
0
二维码
打赏
海报
PHP随机风景图片接口源码
[alert class="success"]#(滑稽)再也不用bing每日图片了,用大米API自己也能换风景图[/alert]
所有图片格式均为.JPG,支持JSON输出。
<?php
/**
*2019-1……

0xe8bfb7e6818be887aae79599e59cb0
0x73686d696c79@0xe8bfb7e6818be887aae79599e59cb0
0x6c61746577697368403132362e636f6d