首页
微语
统计
友链
留言
memos
圈子
图床
推荐
相册
网站监控
VPS监控
Search
1
实现typecho微信时光机功能的图文教程
52,710 阅读
2
为Typecho添加webp解析
44,684 阅读
3
Memos备忘录,记录瞬间想法
31,226 阅读
4
Jasmine - 简约、美观的博客主题
30,235 阅读
5
emlog数据成功迁移到typecho
29,540 阅读
手机达人
免费资源
电脑网络
娱乐休闲
网站建设
威言威语
Typecho
Emlog
WordPress
服务器
主题
插件
排行榜    
登录
/
注册
Search
标签搜索
wordpress
发布
插件
免费
教程
typecho
EMlog
PHP
代码
CSS
华为
图片
安装
代码修改
评论
手机
诺基亚
微信
文章
智能
Chen'mo
累计撰写
1,272
篇文章
累计收到
385
条评论
首页
栏目
手机达人
免费资源
电脑网络
娱乐休闲
网站建设
威言威语
Typecho
Emlog
WordPress
服务器
主题
插件
页面
微语
统计
友链
留言
memos
推荐
相册
网站监控
VPS监控
搜索到
1
篇与
的结果
2022-09-26
Joe主题-壁纸代码改造
前言Joe主题有写好的壁纸模版,直接启用即可。刚开始博主感觉分类太多了,有些分类也不是自己喜欢的。就没有启用,最近有时间研究了一下代码。改造了一下,只留下自己感兴趣的分类。核心代码主要是core/route.php文件内的两个函数,调用了360的壁纸接口,原版如下/* 获取壁纸分类 已测试 √ */ function _getWallpaperType($self) { $self->response->setStatus(200); $json = _curl("http://cdn.apc.360.cn/index.php?c=WallPaper&a=getAllCategoriesV2&from=360chrome"); $res = json_decode($json, TRUE); if ($res['errno'] == 0) { $self->response->throwJson([ "code" => 1, "data" => $res['data'] ]); } else { $self->response->throwJson([ "code" => 0, "data" => null ]); } } /* 获取壁纸列表 已测试 √ */ function _getWallpaperList($self) { $self->response->setStatus(200); $cid = $self->request->cid; $start = $self->request->start; $count = $self->request->count; $json = _curl("http://wallpaper.apc.360.cn/index.php?c=WallPaper&a=getAppsByCategory&cid={$cid}&start={$start}&count={$count}&from=360chrome"); $res = json_decode($json, TRUE); if ($res['errno'] == 0) { $self->response->throwJson([ "code" => 1, "data" => $res['data'], "total" => $res['total'] ]); } else { $self->response->throwJson([ "code" => 0, "data" => null ]); } }优化主要优化 _getWallpaperType 函数,去掉不想要的分类/* 获取壁纸分类 已测试 √ */ function _getWallpaperType($self) { $self->response->setStatus(200); $json = _curl("http://cdn.apc.360.cn/index.php?c=WallPaper&a=getAllCategoriesV2&from=360chrome"); $res = json_decode($json, TRUE); //$file=dirname(__FILE__).'/debug.log'; //保留喜欢的分类 $ilike = ['6', '12', '13', '22']; $re_arr = array(); foreach ($res['data'] as $key => $value) { if (in_array($value['id'], $ilike, true)){ //file_put_contents($file, $value['name']."\n",FILE_APPEND); array_push($re_arr, $value); } } if ($res['errno'] == 0) { $self->response->throwJson([ "code" => 1, "data" => $re_arr ]); } else { $self->response->throwJson([ "code" => 0, "data" => null ]); } }效果首页美女发现是固定的,又懒得翻页。加了个随机,每次刷新都是不同的。/* 获取壁纸列表 已测试 √ */ function _getWallpaperList($self) { $self->response->setStatus(200); $cid = $self->request->cid; //前50页随机显示图片 if (($cid == 6)&&($self->request->start < 2400)) { $start = $self->request->start + rand(1,4800); }else { $start = $self->request->start; } $count = $self->request->count; //$file=dirname(__FILE__).'/debug.log'; //file_put_contents($file, $cid."|".$start."|".$count."\n",FILE_APPEND); $json = _curl("http://wallpaper.apc.360.cn/index.php?c=WallPaper&a=getAppsByCategory&cid={$cid}&start={$start}&count={$count}&from=360chrome"); $res = json_decode($json, TRUE); if ($res['errno'] == 0) { $self->response->throwJson([ "code" => 1, "data" => $res['data'], "total" => $res['total'] ]); } else { $self->response->throwJson([ "code" => 0, "data" => null ]); } }
2022年09月26日
7,541 阅读
0 评论
0 点赞