Code Monkey home page Code Monkey logo

mobile-acg's Introduction

mobile-acg

一个PHP开发的HTTP API,随机获取一张或多张来自Telegram频道 t.me/MikuArt 的适合竖屏移动设备查看的二次元图片,并上传到今日头条的图床,支持JSON获取地址或直接跳转。

网络上其实有很多类似的API,但基本都不开源,不能自行部署,服务稳定性没有保障。并且许多接口内置的图片较少,或者很久都不再更新了。所以我就自己写了一个。调用的是Telegram地址,上传到今日头条的图床,并且可以自行部署,服务稳定性有保障。另外Telegram频道@MikuArt这个频道存在时间很长了,每天都维持着一个很高的更新频率。

使用API

我提供的API:https://api.skyju.cc/mobile-acg/api.php

所有图片均为jpg格式。

你也可以自己搭建(见下文)。

以JSON格式随机获取一张或多张图片的地址

GET参数 值类型 是否可选 说明
method "json": String 本接口规定的method值
count Int 1-1000的整数,指定返回图片的个数;不指定则为1

当请求成功时,返回JSON中的data是一个数组对象;否则为错误信息。

示例请求:

curl "https://api.skyju.cc/mobile-acg/api.php?method=json&count=2"

示例返回:

{
    "status": true,
    "data": [
        {
            "id": 8152,
            "url": "https://p.pstatp.com/origin/1377b000109dcb474c743"
        },
        {
            "id": 7216,
            "url": "https://p.pstatp.com/origin/1380800010f4d9fd7f254"
        }
    ]
}

随机或指定ID获取一张图片并跳转到地址

GET参数 值类型 是否可选 说明
method "get": String 本接口规定的method值
id Int 图片的ID;不指定为随机获取

示例请求:

curl -v "https://api.skyju.cc/mobile-acg/api.php?method=get"

示例返回:

...
HTTP/1.1 302 Found
Location: https://p.pstatp.com/origin/1384d00016e9a0aa34dae
...

示例请求:

curl -v "https://api.skyju.cc/mobile-acg/api.php?method=get&id=9876"

示例返回:

...
HTTP/1.1 302 Found
Location: https://p.pstatp.com/origin/1384e00040d776e8f2486
...

在VPS上部署本项目

1.切换到你的站点目录:

cd /path/to/your/www/

2.拉取本项目:

git clone https://github.com/juzeon/mobile-acg.git mobile-acg

3.添加cron任务每日从Telegram更新图片,上传并存储到数据库:

0 1 * * * php /path/to/your/www/mobile-acg/update-cli.php # 每日凌晨一点更新

4.访问你的网站相应地址,检查API可用性。

mobile-acg's People

Contributors

juzeon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.