后端技术 · Develop

自建Menhera酱表情包api

•̀.̫•́✧ · 7月19日 · 2019年

昨天添加了一个Menhera相册,总觉得还是少了点什么,于是乎就写了一个api把Menhera酱表情包封装在里面。 方便动态随机获取展示了。就是要搞点事情,嘿嘿。。。那么下面开始吧

1.上传表情包

我这里用到的是 https://upload.cc/ ,方便之处在于一次可以上传10个图片文件

自建Menhera酱表情包api-歪?是3.1415926吗

也可以使用本博主自己搭建的api图床 https://www.zsxcool.com/img

2.代码实例

上传完毕后,将得到图片直链链接保存

下面是PHP代码实例

<?php
$url[1]="https://upload.cc/i1/2019/06/27/3jsp7m.jpg"; 
$url[2]="https://upload.cc/i1/2019/06/27/R6HCJS.jpg"; 
$url[3]="https://upload.cc/i1/2019/06/27/81XIvd.jpg"; 
$url[4]="https://upload.cc/i1/2019/06/27/yW0XrL.jpg"; 
$url[5]="https://upload.cc/i1/2019/06/27/ulyFOH.jpg"; 
$url[6]="https://upload.cc/i1/2019/06/27/wsHLKf.jpg"; 
$url[7]="https://upload.cc/i1/2019/06/27/okc52I.jpg"; 
$url[8]="https://upload.cc/i1/2019/06/27/JdSkh9.jpg"; 
$url[9]="https://upload.cc/i1/2019/06/27/oZflth.jpg"; 
$url[10]="https://upload.cc/i1/2019/06/27/DUot9v.jpg"; 
$url[11]="https://upload.cc/i1/2019/06/27/My3Khz.jpg"; 
$url[12]="https://upload.cc/i1/2019/06/27/uSxljb.jpg"; 
$url[13]="https://upload.cc/i1/2019/06/27/9vkUf7.jpg"; 
$url[14]="https://upload.cc/i1/2019/06/27/pjJwFA.jpg"; 
$url[15]="https://upload.cc/i1/2019/06/27/uHgSGX.jpg"; 
$url[16]="https://upload.cc/i1/2019/06/27/c3iJym.jpg"; 
$url[17]="https://upload.cc/i1/2019/06/27/uRrtHb.jpg"; 
$url[18]="https://upload.cc/i1/2019/06/27/gIlpSm.jpg"; 
$url[19]="https://upload.cc/i1/2019/06/27/qcg8k3.jpg"; 
$url[20]="https://upload.cc/i1/2019/06/27/bXUYfJ.jpg"; 
$url[21]="https://upload.cc/i1/2019/06/27/qYbk2N.jpg"; 
$url[22]="https://upload.cc/i1/2019/06/27/VQpirJ.jpg"; 
$url[23]="https://upload.cc/i1/2019/06/27/LndGzT.jpg"; 
$url[24]="https://upload.cc/i1/2019/06/27/WdOfLK.jpg"; 
$url[25]="https://upload.cc/i1/2019/06/27/JuGb5p.jpg"; 
$url[26]="https://upload.cc/i1/2019/06/27/w0DyiW.jpg"; 
$url[27]="https://upload.cc/i1/2019/06/27/r5LmTD.jpg"; 
$url[28]="https://upload.cc/i1/2019/06/27/MrboSn.jpg"; 
$url[29]="https://upload.cc/i1/2019/06/27/KCujLk.jpg"; 
$url[30]="https://upload.cc/i1/2019/06/27/d5N8o2.jpg"; 
$url[31]="https://upload.cc/i1/2019/06/27/UsJVb9.jpg"; 
$url[32]="https://upload.cc/i1/2019/06/27/pafUYe.jpg"; 
$url[33]="https://upload.cc/i1/2019/06/27/pSLKj6.jpg"; 
$url[34]="https://upload.cc/i1/2019/06/27/9SPUnx.jpg"; 
$url[35]="https://upload.cc/i1/2019/06/27/wcy0nk.jpg"; 
$url[36]="https://upload.cc/i1/2019/06/27/P3z52D.jpg"; 
$url[37]="https://upload.cc/i1/2019/06/27/nsexhH.jpg"; 
$url[38]="https://upload.cc/i1/2019/06/27/LQKfpx.jpg"; 
$url[39]="https://upload.cc/i1/2019/06/27/nICVOW.jpg"; 
$url[40]="https://upload.cc/i1/2019/06/27/lWR3Ot.jpg"; 
$url[41]="https://upload.cc/i1/2019/06/27/v7tmNK.jpg"; 
$url[42]="https://upload.cc/i1/2019/06/27/l7V2w3.jpg"; 
$url[43]="https://upload.cc/i1/2019/06/27/d2TH3C.jpg"; 
$url[44]="https://upload.cc/i1/2019/06/27/f7EO4Q.jpg"; 
$url[45]="https://upload.cc/i1/2019/06/27/keB7WE.jpg"; 
$url[46]="https://upload.cc/i1/2019/06/27/xKpvcf.jpg"; 
$url[47]="https://upload.cc/i1/2019/06/27/vI1zeW.jpg"; 
$url[48]="https://upload.cc/i1/2019/06/27/7VGLgo.jpg"; 
$url[49]="https://upload.cc/i1/2019/06/27/JKG9ZL.jpg"; 
$url[50]="https://upload.cc/i1/2019/06/27/KYPlRj.jpg"; 
$url[51]="https://upload.cc/i1/2019/06/27/gryBOb.jpg"; 
$url[52]="https://upload.cc/i1/2019/06/27/rjoS1O.jpg"; 
$url[53]="https://upload.cc/i1/2019/06/27/PNtdrh.jpg"; 
$url[54]="https://upload.cc/i1/2019/06/27/AzMcQg.jpg"; 
$url[55]="https://upload.cc/i1/2019/06/27/nlEYzH.jpg"; 
$url[56]="https://upload.cc/i1/2019/06/27/V0IKWg.jpg"; 
$url[57]="https://upload.cc/i1/2019/06/27/kECK9r.jpg"; 
$url[58]="https://upload.cc/i1/2019/06/27/tsSPvn.jpg"; 
$url[59]="https://upload.cc/i1/2019/06/27/XhuIor.jpg"; 
$url[60]="https://upload.cc/i1/2019/06/27/Kfc9LA.jpg"; 
$url[61]="https://upload.cc/i1/2019/06/27/wUSs5b.jpg"; 
$url[62]="https://upload.cc/i1/2019/06/27/M4drKN.jpg"; 
$url[63]="https://upload.cc/i1/2019/06/27/ivE8Tw.jpg"; 
$url[64]="https://upload.cc/i1/2019/06/27/20slC1.jpg"; 
$url[65]="https://upload.cc/i1/2019/06/27/Q0X5W6.jpg"; 
$url[66]="https://upload.cc/i1/2019/06/27/jC7NFS.jpg"; 
$url[67]="https://upload.cc/i1/2019/06/27/zqD3nL.jpg"; 
$url[68]="https://upload.cc/i1/2019/06/27/0NkmT9.jpg"; 
$url[69]="https://upload.cc/i1/2019/06/27/sDZTC2.jpg"; 
$url[70]="https://upload.cc/i1/2019/06/27/iFIByM.jpg"; 
$url[71]="https://upload.cc/i1/2019/06/27/4OUlnr.jpg"; 
srand ((double)microtime()*1000000);
$randomnum = rand(0, count($url)-1);
header ("Location: $url[$randomnum]");
?>

如果你还要对接其他图片API的话可以试试这个代码

<?php
$urls = [
  'https://www.zsxcool.com/api/Menhera_api/index.php',
  'https://api.uomg.com/api/rand.img1',
];
header('Location: '.$urls[mt_rand(0, count($urls)-1)]);

把上面代码保存为一个php文件即可,上面内容改成你的或者用我的。 这样就可以随机显示两个随机图片API中的随机图片啦。

3. 预览图

4.接口地址

https://www.zsxcool.com/api/Menhera_api/Menhera_api.php

1 条回应
  1. iVampireSP2019-7-19 · 15:18

    我不推荐用这个代码。。容易丢图片。我记得压缩包里放了161张,这只有71张。