之前上传过新浪外链的接口,但是现在新浪已经挂了,所以重新写份给大家
接口代码:
<?php
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;
}
$str = explode("\n", file_get_contents('1.txt'));
$key = rand(0, count($str));
$imgUrl = str_re($str[$key]);
$result = array("code" => "200", "imgurl" => "$imgUrl");
var_dump($imgUrl);
$type = $_GET['format'];
switch ($type) {
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;
}
txt文件代码:
https://ae01.alicdn.com/kf/H1a0f7cf89fa747a09dfa39461a4146ec3.jpg
https://ae01.alicdn.com/kf/H7acdaa82559449a6ae64b6adeabecc68E.jpg
https://ae01.alicdn.com/kf/H8e1de47b1804457ea520e380e557e67f6.jpg
https://ae01.alicdn.com/kf/H59412cf917064dfdb0e4674d44020e64Y.jpg
https://ae01.alicdn.com/kf/Hff0a81987480473fb786ad10d5ef8f65M.jpg
https://ae01.alicdn.com/kf/H976885e5584549dbbdc4409dc2337795r.jpg
https://ae01.alicdn.com/kf/H7cd6b23cbf4b4f8db8b35e41f612c7eak.jpg
https://ae01.alicdn.com/kf/H328dcf6fa0014802a531f37b8a0b2b93D.jpg
图片就不分享了,你们自己找图床上传写入即可
##私密评论仅博主可见##
##私密评论仅博主可见##
5156156156才
祖安大舞台