Joe主题-壁纸代码改造

it不难
2022-08-07 / 1 评论 / 30 阅读 / 正在检测是否收录...

前言

核心代码

/* 获取壁纸分类 已测试 √ */
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
        ]);
    }
}

优化

/* 获取壁纸列表 已测试 √ */
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
        ]);
    }
}
0

评论 (1)

取消
  1. 头像
    chenmo
    中国湖南省 · Windows 10 · Google Chrome
    沙发

    这个不错,那我也去弄一个。表情

    回复