【网站代码】自制随机图片api
下面代码只适于新浪图片 <?php //读取文本 $str = explode("\n", file_get_contents('wpimg.txt')); //txt文件是存储新浪图片的代码 $k = rand(0,count($str)); $sina_img = str_re($str[$k]); $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://tva'.$server.'.sinaimg.cn/'.$size.'/'.$sina_img.'.jpg'; //解析结果 $result=array("code"=>"200","imgurl"=>"$url"); //Type Choose参数代码 $type=$_GET['return']; switch ($type) { //Json格式解析 case 'json': $imageInfo = getimagesize($url); $result['width']="$imageInfo[0]"; $result['height']="$imageInfo[1]"; header('Content-type:text/json'); echo json_encode($result); break; //IMG default: header("Location:".$result['imgurl']); break; } function str_re($str){ $str = str_replace(' ', "", $str); $str = str_replace("\n", "", $str); $str = str_replace("\t", "", $str); $str = str_replace("\r", "", $str); return $str; } ?> 然后在创建个txt文件 txt文本里面的格式只取新浪外链图片的红色部分,一行一个 如:https://ws4.sinaimg.cn/large/65b17112ly1fv5ll42bsqj21hc0xc4b9.jpg 65b17112ly1fv5ll42bsqj21hc0xc4b9 65b17112ly1fv5ll4a2ktj21hc0xcqbi 65b17112ly1fv5ll4i3jnj21hc0xcwo3 65b17112ly1fv5ll4syu4j21hc0xcame 65b17112ly1fv5ll52zw7j21hc0xc7gz 65b17112ly1fv5ll5a4bwj21hc0xcak3 65b17112ly1fv5ll5imk2j21hc0xcn9o 65b17112ly1fv5ll5sc5wj21hc0xc14u 65b17112ly1fv5ll5zis3j21hc0xcgv9 65b17112ly1fv5ll67wiej21hc0xcwiu 65b17112ly1fv5lm7c4ksj21hc0xcgtw 65b17112ly1fv5lm7lfr9j21hc0xcdr2 65b17112ly1fv5lm7u9tsj21hc0xcqal 65b17112ly1fv5lm81p92j21hc0xck4s 65b17112ly1fv5lm8bb89j21hc0xck1x 65b17112ly1fv5lm8l94dj21hc0xck29 65b17112ly1fv5lm8ryeqj21hc0xcn6f 65b17112ly1fv5lm8zq87j21hc0xcwpj 65b17112ly1fv5lm98f8yj21hc0xcn7r 65b17112ly1fv5lm9rikgj21hc0xc7aq 65b17112ly1fv5lmv4gkhj21hc0xc111 65b17112ly1fv5lmvd7avj21hc0xc46t 65b17112ly1fv5lmvkny0j21hc0xcjxu 65b17112ly1fv5lmvrez9j21hc0xcai2 65b17112ly1fv5lmw0kqrj21hc0xck1i 65b17112ly1fv5lmw8j37j21hc0xc10r 65b17112ly1fv5lmwi1xzj21hc0xc0zh 65b17112ly1fv5lmwox42j21hc0xctk2 65b17112ly1fv5lmwzcqqj21hc0xc13i 65b17112ly1fv5lmx96v2j21hc0xcdr5 65b17112ly1fv5lmxkxwbj21hc0xcagl 65b17112ly1fv5lmxsnydj21hc0xc7b7 65b17112ly1fv5lmy5imtj21hc0xcgtl 65b17112ly1fv5lmyewwtj21hc0xcamh 65b17112ly1fv5lmyo0w7j21hc0xcwrz 65b17112ly1fv5lnpt8npj21hc0xcgrh 65b17112ly1fv5lnpz9avj21hc0xcdjh 65b17112ly1fv5lnq7vowj21hc0xcq8r 65b17112ly1fv5lnqh1f5j21hc0xcgv9 65b17112ly1fv5lnqr6u8j21hc0xcguj 65b17112ly1fv5lnqzat7j21hc0xcn4v 65b17112ly1fv5lnr69pjj21hc0xc7cr 65b17112ly1fv5lnrg8tzj21hc0xc46k 65b17112ly1fv5lnspfbvj21hc0xcdky 65b17112ly1fv5lnsxlizj21hc0xcdlu 65b17112ly1fv5lnt4yu2j21hc0xcwjb 65b17112ly1fv5lnteluij21hc0xck1e
如果你觉得雨滴资源网对你有帮助的话,可以小小的打赏一下小站,用于维持本站的运营!
版权声明:雨滴资源网内容来源于互联网,如果有侵权内容、不妥之处,请第一时间联系我们删除。敬请谅解!
本文链接:【网站代码】自制随机图片api - https://www.yudzy.com/398.html
失效提示:此文更新于2019-6-12,如果文章内容或图片资源失效,请留言反馈,客服会及时处理,谢谢!