嘛,没事发呆,就搞了个从P站里面抽的图随机给文章换成缩略图
2333反正博客也没嘛人来呢
图源来自夏鄕自己的Pixiv墙
自己输出了个接口,用于输出随机图的json数据
http://galgames.ml/pre_to_my_blog.php
然后博客端就搞一搞主题喽
2333
核心参数
//图库缩略图助攻博客
function getCurlFile($url, $timeout = 3) //使用curl函数获取,如果你的PHP空间不支持此函数,自己替换成上面的file_get_contents
{
$ch = curl_init();
// 设置 curl 相应属性
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$returnTransfer = curl_exec($ch);
curl_close($ch);
return $returnTransfer;
}
$data=getCurlFile(‘http://galgames.ml/pre_to_my_blog.php’);
$pre_data=json_decode($data);
if(empty($pre_data)){
$pre_data=array();
for($i=0;$i<10;$i++){
$pre_data[$i]=new stdClass();
$pre_data[$i]->title=’本次超时替换默认';
$pre_data[$i]->preview=’http://i2.pixiv.net/img04/img/yuyalain/mobile/42706549_240mw.jpg';
$pre_data[$i]->image=’http://www.pixiv.net/member_illust.php?mode=big&illust_id=42706549′;
}
}
下面的就是遍历数组呢,本博就不写出来了啦
我怎么就不能花点时间学编程呢 Orz
依然看不懂代码
我汉子,你才妹子
流量大了,域名就会被收回吧,和tk一样233,还是买个吧~
博主是妹子还是汉子呢?
哈,那拿我的图片去撸吧
欧尼酱 好厉害