免费随机图片api接口(转载)
本文发布于 368 天前,最后更新于368天前,其中的信息可能已经有所发展或是发生改变,如有需要,请联系我([email protected])进行更新吖~

1、api接口整合

近期由于新浪对图片设置了防盗链,所以许多api已失效,本站api已恢复正常


樱花:https://www.dmoe.cc/random.php
搏天:https://api.btstu.cn/sjbz/api.php
樱道:https://api.r10086.com/img-api.php?type=动漫综合1
小歪:https://api.ixiaowai.cn/api/api2.php
保罗:https://api.paugram.com/wallpaper
墨天逸:https://api.mtyqx.cn/tapi/random.php
EEE.DOG:https://api.yimian.xyz/img
东方Project:https://img.paulzzh.tech/touhou/random
likepoems随机图:https://api.likepoems.com/img/aliyun/mc
洛川唧上的萌部图片:
https://service-5z0sdahv-1306777571.sh.apigw.tencentcs.com/release/
Unsplash Image:https://source.unsplash.com/random
缙哥哥博客: https://api.dujin.org/pic/yuanshen/
其它随机图:https://api.wuque.cc/random/images

2、api网站整合

2.1 樱花 (已失效)

网址:https://www.dmoe.cc/

2.2 搏天

网址:https://api.btstu.cn/doc/sjbz.php

2.3 樱道 (访问较慢)

网址:https://img.r10086.com/

2.4 小歪

网址:https://api.ixiaowai.cn/

2.5 保罗 (访问较慢)

网址:https://api.paugram.com/help/wallpaper

2.6 墨天逸 (已失效)

网址:https://api.mtyqx.cn/

2.7 EEE.DOG

网址:https://www.eee.dog/tech/rand-pic-api.html

2.8 东方Project

网址:https://img.paulzzh.tech/

2.9 likepoems随机图

网址:
https://api.likepoems.com/

2.10 洛川唧上的萌部图片 (已失效)

网址:https://tu-api.df100.ltd/

2.11 Unsplash Image

网址:https://source.unsplash.com/

2.12 缙哥哥博客 (访问较慢)

网址:https://api.dujin.org/pic/yuanshen/

2.13 其它随机图 (已失效)

网址:https://api.wuque.cc/random/images

3、怎么自制随机图

3.1 普通的随机图

准备图片—>书写路径—>书写php文件
在img文件夹里新建img.txt,文件中直接写图片的URL地址,如:

https://static.likepoems.com/2020/10/06/385ea1c4c8b4fbac57f5a0aa61f033761.jpghttps://static.likepoems.com/2021/06/12/20210126104630786.png

新建index.php文件。文件内容如下:

<?php//存放api随机图链接的文件名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)]; //返回指定格式$type=$_GET['type'];switch($type){ //JSON返回case 'json':    header('Content-type:text/json');    die(json_encode(['pic'=>$pic])); default:    die(header("Location: $pic"));} ?>

然后放在服务器里面的api文件夹里,绑定域名,记得开启php环境
访问路径:你的域名/api/img

3.2 通过新浪微博图床搭建的随机图

index.php

<?php//读取文本$str = explode("\n", file_get_contents('img.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';//解析url$result=array("code"=>"200","imgurl"=>"$url");//定义type返回类型$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;//返回图片链接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;}?>

img.txt

007LvBV9gy1h4ogsz8i56j31hc0u0h99007LvBV9gy1h4ogszkea5j31hc0u0qko007LvBV9gy1h4ogszvqhuj31hc0u0k8t007LvBV9gy1h4ogt05g8sj30xc0n3gue007LvBV9gy1h4ogt0hx1qj31hc0xc7il

和上面的一样,只是请求的是微博的图片,比较稳定,速度快。
请求示例:
你的域名/api/img?return=json 返回json格式
你的域名/api/img 返回普通图片

5.转载

原文链接:https://likepoems.com/articles/free-random-image-api-interface/
来源:likepoems,谢谢!^^

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇
Copyright 2023 Space520
PoweredWordPress
Running Time days H M S
Theme Argon
| 耗时 0.236 秒 | 查询 34 次 | 内存 18.92 MB |